/* language.rs
Copyright (C) 2024-2025, Wenjian Chern.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>. */

use std::collections::HashMap;

use lazy_static::lazy_static;
use rayon::prelude::*;

/// Return the BCP 47 code.
pub fn language(id: u16) -> Option<&'static str> {
    if id < 0x0400 {
        Some(MACOS_TABLE.par_iter().find_any(|&&(i, ..)| i == id)?.2)
    } else {
        Some(WINDOWS_TABLE.par_iter().find_any(|&&(i, ..)| i == id)?.2)
    }
}

/// Return the language name.
pub fn language_str(id: u16) -> Option<&'static str> {
    if id < 0x0400 {
        Some(MACOS_TABLE.par_iter().find_any(|&&(i, ..)| i == id)?.3)
    } else {
        Some(WINDOWS_TABLE.par_iter().find_any(|&&(i, ..)| i == id)?.3)
    }
}

pub fn is_same_primary_language(l1: &str, l2: &str) -> bool {
    if let Some(lang) = LANG_TAG_PRIMARY_LANGUAGE.get(l1) {
        Some(lang) == LANG_TAG_PRIMARY_LANGUAGE.get(l2)
    } else {
        false
    }
}

// https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
#[rustfmt::skip]
static MACOS_TABLE: &[(u16, PrimaryLanguage, &str, &str)] = &[
    (0, PrimaryLanguage::English, "en", "English"),
    (1, PrimaryLanguage::French, "fr", "French"),
    (2, PrimaryLanguage::German, "de", "German"),
    (3, PrimaryLanguage::Italian, "it", "Italian"),
    (4, PrimaryLanguage::Dutch, "nl", "Dutch"),
    (5, PrimaryLanguage::Swedish, "sv", "Swedish"),
    (6, PrimaryLanguage::Spanish, "es", "Spanish"),
    (7, PrimaryLanguage::Danish, "da", "Danish"),
    (8, PrimaryLanguage::Portuguese, "pt", "Portuguese"),
    (9, PrimaryLanguage::Norwegian, "nb", "Norwegian"),
    (10, PrimaryLanguage::Hebrew, "he", "Hebrew"),
    (11, PrimaryLanguage::Japanese, "ja", "Japanese"),
    (12, PrimaryLanguage::Arabic, "ar", "Arabic"),
    (13, PrimaryLanguage::Finnish, "fi", "Finnish"),
    (14, PrimaryLanguage::Greek, "el", "Greek"),
    (15, PrimaryLanguage::Icelandic, "is", "Icelandic"),
    (16, PrimaryLanguage::Maltese, "mt", "Maltese"),
    (17, PrimaryLanguage::Turkish, "tr", "Turkish"),
    (18, PrimaryLanguage::Croatian, "hr", "Croatian"),
    (19, PrimaryLanguage::Chinese, "zh-Hant", "Chinese (Traditional)"),
    (20, PrimaryLanguage::Urdu, "ur", "Urdu"),
    (21, PrimaryLanguage::Hindi, "hi", "Hindi"),
    (22, PrimaryLanguage::Thai, "th", "Thai"),
    (23, PrimaryLanguage::Korean, "ko", "Korean"),
    (24, PrimaryLanguage::Lithuanian, "lt", "Lithuanian"),
    (25, PrimaryLanguage::Polish, "pl", "Polish"),
    (26, PrimaryLanguage::Hungarian, "hu", "Hungarian"),
    (27, PrimaryLanguage::Estonian, "et", "Estonian"),
    (28, PrimaryLanguage::Latvian, "lv", "Latvian"),
    (29, PrimaryLanguage::Sami, "se", "Sami"),
    (30, PrimaryLanguage::Faroese, "fo", "Faroese"),
    (31, PrimaryLanguage::Farsi, "fa", "Farsi/Persian"),
    (32, PrimaryLanguage::Russian, "ru", "Russian"),
    (33, PrimaryLanguage::Chinese, "zh-Hans", "Chinese (Simplified)"),
    (34, PrimaryLanguage::Flemish, "nl", "Flemish"),
    (35, PrimaryLanguage::Irish, "ga", "Irish Gaelic"),
    (36, PrimaryLanguage::Albanian, "sq", "Albanian"),
    (37, PrimaryLanguage::Romanian, "ro", "Romanian"),
    (38, PrimaryLanguage::Czech, "cs", "Czech"),
    (39, PrimaryLanguage::Slovak, "sk", "Slovak"),
    (40, PrimaryLanguage::Slovenian, "sl", "Slovenian"),
    (41, PrimaryLanguage::Yiddish, "yi", "Yiddish"),
    (42, PrimaryLanguage::Serbian, "sr", "Serbian"),
    (43, PrimaryLanguage::Macedonian, "mk", "Macedonian"),
    (44, PrimaryLanguage::Bulgarian, "bg", "Bulgarian"),
    (45, PrimaryLanguage::Ukrainian, "uk", "Ukrainian"),
    (46, PrimaryLanguage::Byelorussian, "be", "Byelorussian"),
    (47, PrimaryLanguage::Uzbek, "uz", "Uzbek"),
    (48, PrimaryLanguage::Kazakh, "kk", "Kazakh"),
    (49, PrimaryLanguage::Azerbaijani, "az-Cyrl", "Azerbaijani (Cyrillic script)"),
    (50, PrimaryLanguage::Azerbaijani, "az-Arab", "Azerbaijani (Arabic script)"),
    (51, PrimaryLanguage::Armenian, "hy", "Armenian"),
    (52, PrimaryLanguage::Georgian, "ka", "Georgian"),
    (53, PrimaryLanguage::Moldavian, "mo", "Moldavian"),
    (54, PrimaryLanguage::Kirghiz, "ky", "Kirghiz"),
    (55, PrimaryLanguage::Tajiki, "tg", "Tajiki"),
    (56, PrimaryLanguage::Turkmen, "tk", "Turkmen"),
    (57, PrimaryLanguage::Mongolian, "mn-Mong", "Mongolian (Mongolian script)"),
    (58, PrimaryLanguage::Mongolian, "mn-Cyrl", "Mongolian (Cyrillic script)"),
    (59, PrimaryLanguage::Pashto, "ps", "Pashto"),
    (60, PrimaryLanguage::CentralKurdish, "ku", "Kurdish"),
    (61, PrimaryLanguage::Kashmiri, "ks", "Kashmiri"),
    (62, PrimaryLanguage::Sindhi, "sd", "Sindhi"),
    (63, PrimaryLanguage::Tibetan, "bo", "Tibetan"),
    (64, PrimaryLanguage::Nepali, "ne", "Nepali"),
    (65, PrimaryLanguage::Sanskrit, "sa", "Sanskrit"),
    (66, PrimaryLanguage::Marathi, "mr", "Marathi"),
    (67, PrimaryLanguage::Bengali, "bn", "Bengali"),
    (68, PrimaryLanguage::Assamese, "as", "Assamese"),
    (69, PrimaryLanguage::Gujarati, "gu", "Gujarati"),
    (70, PrimaryLanguage::Punjabi, "pa", "Punjabi"),
    (71, PrimaryLanguage::Oriya, "or", "Oriya"),
    (72, PrimaryLanguage::Malayalam, "ml", "Malayalam"),
    (73, PrimaryLanguage::Kannada, "kn", "Kannada"),
    (74, PrimaryLanguage::Tamil, "ta", "Tamil"),
    (75, PrimaryLanguage::Telugu, "te", "Telugu"),
    (76, PrimaryLanguage::Sinhalese, "si", "Sinhalese"),
    (77, PrimaryLanguage::Burmese, "my", "Burmese"),
    (78, PrimaryLanguage::Khmer, "km", "Khmer"),
    (79, PrimaryLanguage::Lao, "lo", "Lao"),
    (80, PrimaryLanguage::Vietnamese, "vi", "Vietnamese"),
    (81, PrimaryLanguage::Indonesian, "id", "Indonesian"),
    (82, PrimaryLanguage::Tagalog, "tl", "Tagalog"),
    (83, PrimaryLanguage::Malay, "ms-Latn", "Malay (Roman script)"),
    (84, PrimaryLanguage::Malay, "ms-Arab", "Malay (Arabic script)"),
    (85, PrimaryLanguage::Amharic, "am", "Amharic"),
    (86, PrimaryLanguage::Tigrinya, "ti", "Tigrinya"),
    (87, PrimaryLanguage::Galla, "om", "Galla"),
    (88, PrimaryLanguage::Somali, "so", "Somali"),
    (89, PrimaryLanguage::Swahili, "sw", "Swahili"),
    (90, PrimaryLanguage::Kinyarwanda, "rw", "Kinyarwanda/Ruanda"),
    (91, PrimaryLanguage::Rundi, "rn", "Rundi"),
    (92, PrimaryLanguage::Nyanja, "ny", "Nyanja/Chewa"),
    (93, PrimaryLanguage::Malagasy, "mg", "Malagasy"),
    (94, PrimaryLanguage::Esperanto, "eo", "Esperanto"),
    (128, PrimaryLanguage::Welsh, "cy", "Welsh"),
    (129, PrimaryLanguage::Basque, "eu", "Basque"),
    (130, PrimaryLanguage::Catalan, "ca", "Catalan"),
    (131, PrimaryLanguage::Latin, "la", "Latin"),
    (132, PrimaryLanguage::Quechua, "quz", "Quechua"),
    (133, PrimaryLanguage::Guarani, "gn", "Guarani"),
    (134, PrimaryLanguage::Aymara, "ay", "Aymara"),
    (135, PrimaryLanguage::Tatar, "tt", "Tatar"),
    (136, PrimaryLanguage::Uighur, "ug", "Uighur"),
    (137, PrimaryLanguage::Dzongkha, "dz", "Dzongkha"),
    (138, PrimaryLanguage::Javanese, "jv-Latn", "Javanese (Roman script)"),
    (139, PrimaryLanguage::Sundanese, "su-Latn", "Sundanese (Roman script)"),
    (140, PrimaryLanguage::Galician, "gl", "Galician"),
    (141, PrimaryLanguage::Afrikaans, "af", "Afrikaans"),
    (142, PrimaryLanguage::Breton, "br", "Breton"),
    (143, PrimaryLanguage::Inuktitut, "iu", "Inuktitut"),
    (144, PrimaryLanguage::ScottishGaelic, "gd", "Scottish Gaelic"),
    (145, PrimaryLanguage::Manx, "gv", "Manx Gaelic"),
    (146, PrimaryLanguage::Irish, "ga", "Irish Gaelic (with dot above)"),
    (147, PrimaryLanguage::Tongan, "to", "Tongan"),
    (148, PrimaryLanguage::Greek, "el", "Greek (Polytonic)"),
    (149, PrimaryLanguage::Greenlandic, "kl", "Greenlandic"),
    (150, PrimaryLanguage::Azerbaijani, "az-Latn", "Azerbaijani (Roman script)"),
    (151, PrimaryLanguage::Norwegian, "nn", "Norwegian (Nynorsk)"),
];

// https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f
#[rustfmt::skip]
static WINDOWS_TABLE: &[(u16, Language, &str, &str, &str)] = &[
    (0x0401, Language::Arabic_SaudiArabia, "ar-SA", "Arabic", "Saudi Arabia"),
    (0x0402, Language::Bulgarian_Bulgaria, "bg-BG", "Bulgarian", "Bulgaria"),
    (0x0403, Language::Catalan_Catalan, "ca-ES", "Catalan", "Catalan"),
    (0x0404, Language::Chinese_Traditional_Taiwan, "zh-TW", "Chinese (Traditional)", "Taiwan"),
    (0x0405, Language::Czech_CzechRepublic, "cs-CZ", "Czech", "Czech Republic"),
    (0x0406, Language::Danish_Denmark, "da-DK", "Danish", "Denmark"),
    (0x0407, Language::German_Germany, "de-DE", "German", "Germany"),
    (0x0408, Language::Greek_Greece, "el-GR", "Greek", "Greece"),
    (0x0409, Language::English_UnitedStates, "en-US", "English", "United States"),
    (0x040A, Language::Spanish_TraditionalSort_Spain, "es-ES_tradnl", "Spanish (Traditional Sort)", "Spain"),
    (0x040B, Language::Finnish_Finland, "fi-FI", "Finnish", "Finland"),
    (0x040C, Language::French_France, "fr-FR", "French", "France"),
    (0x040D, Language::Hebrew_Israel, "he-IL", "Hebrew", "Israel"),
    (0x040E, Language::Hungarian_Hungary, "hu-HU", "Hungarian", "Hungary"),
    (0x040F, Language::Icelandic_Iceland, "is-IS", "Icelandic", "Iceland"),
    (0x0410, Language::Italian_Italy, "it-IT", "Italian", "Italy"),
    (0x0411, Language::Japanese_Japan, "ja-JP", "Japanese", "Japan"),
    (0x0412, Language::Korean_Korea, "ko-KR", "Korean", "Korea"),
    (0x0413, Language::Dutch_Netherlands, "nl-NL", "Dutch", "Netherlands"),
    (0x0414, Language::Norwegian_Bokmal_Norway, "nb-NO", "Norwegian (Bokmal)", "Norway"),
    (0x0415, Language::Polish_Poland, "pl-PL", "Polish", "Poland"),
    (0x0416, Language::Portuguese_Brazil, "pt-BR", "Portuguese", "Brazil"),
    (0x0417, Language::Romansh_Switzerland, "rm-CH", "Romansh", "Switzerland"),
    (0x0418, Language::Romanian_Romania, "ro-RO", "Romanian", "Romania"),
    (0x0419, Language::Russian_Russia, "ru-RU", "Russian", "Russia"),
    (0x041A, Language::Croatian_Croatia, "hr-HR", "Croatian", "Croatia"),
    (0x041B, Language::Slovak_Slovakia, "sk-SK", "Slovak", "Slovakia"),
    (0x041C, Language::Albanian_Albania, "sq-AL", "Albanian", "Albania"),
    (0x041D, Language::Swedish_Sweden, "sv-SE", "Swedish", "Sweden"),
    (0x041E, Language::Thai_Thailand, "th-TH", "Thai", "Thailand"),
    (0x041F, Language::Turkish_Turkey, "tr-TR", "Turkish", "Turkey"),
    (0x0420, Language::Urdu_IslamicRepublicOfPakistan, "ur-PK", "Urdu", "Islamic Republic of Pakistan"),
    (0x0421, Language::Indonesian_Indonesia, "id-ID", "Indonesian", "Indonesia"),
    (0x0422, Language::Ukrainian_Ukraine, "uk-UA", "Ukrainian", "Ukraine"),
    (0x0423, Language::Belarusian_Belarus, "be-BY", "Belarusian", "Belarus"),
    (0x0424, Language::Slovenian_Slovenia, "sl-SI", "Slovenian", "Slovenia"),
    (0x0425, Language::Estonian_Estonia, "et-EE", "Estonian", "Estonia"),
    (0x0426, Language::Latvian_Latvia, "lv-LV", "Latvian", "Latvia"),
    (0x0427, Language::Lithuanian_Lithuania, "lt-LT", "Lithuanian", "Lithuania"),
    (0x0428, Language::Tajik_Cyrillic_Tajikistan, "tg-Cyrl-TJ", "Tajik (Cyrillic)", "Tajikistan"),
    (0x0429, Language::Persian_Farsi_Iran, "fa-IR", "Persian (Farsi)", "Iran"),
    (0x042A, Language::Vietnamese_Vietnam, "vi-VN", "Vietnamese", "Vietnam"),
    (0x042B, Language::Armenian_Armenia, "hy-AM", "Armenian", "Armenia"),
    (0x042C, Language::Azeri_Latin_Azerbaijan, "az-Latn-AZ", "Azeri (Latin)", "Azerbaijan"),
    (0x042D, Language::Basque_Basque, "eu-ES", "Basque", "Basque"),
    (0x042E, Language::UpperSorbian_Germany, "hsb-DE", "Upper Sorbian", "Germany"),
    (0x042F, Language::Macedonian_NorthMacedonia, "mk-MK", "Macedonian", "North Macedonia"),
    (0x0432, Language::Setswana_SouthAfrica, "tn-ZA", "Setswana", "South Africa"),
    (0x0434, Language::isiXhosa_SouthAfrica, "xh-ZA", "isiXhosa", "South Africa"),
    (0x0435, Language::isiZulu_SouthAfrica, "zu-ZA", "isiZulu", "South Africa"),
    (0x0436, Language::Afrikaans_SouthAfrica, "af-ZA", "Afrikaans", "South Africa"),
    (0x0437, Language::Georgian_Georgia, "ka-GE", "Georgian", "Georgia"),
    (0x0438, Language::Faroese_FaroeIslands, "fo-FO", "Faroese", "Faroe Islands"),
    (0x0439, Language::Hindi_India, "hi-IN", "Hindi", "India"),
    (0x043A, Language::Maltese_Malta, "mt-MT", "Maltese", "Malta"),
    (0x043B, Language::Sami_Northern_Norway, "se-NO", "Sami (Northern)", "Norway"),
    (0x043D, Language::Yiddish_World, "yi-001", "Yiddish", "World"),
    (0x043E, Language::Malay_Malaysia, "ms-MY", "Malay", "Malaysia"),
    (0x043F, Language::Kazakh_Kazakhstan, "kk-KZ", "Kazakh", "Kazakhstan"),
    (0x0440, Language::Kyrgyz_Kyrgyzstan, "ky-KG", "Kyrgyz", "Kyrgyzstan"),
    (0x0441, Language::Kiswahili_Kenya, "sw-KE", "Kiswahili", "Kenya"),
    (0x0442, Language::Turkmen_Turkmenistan, "tk-TM", "Turkmen", "Turkmenistan"),
    (0x0443, Language::Uzbek_Latin_Uzbekistan, "uz-Latn-UZ", "Uzbek (Latin)", "Uzbekistan"),
    (0x0444, Language::Tatar_Russia, "tt-RU", "Tatar", "Russia"),
    (0x0445, Language::Bengali_India, "bn-IN", "Bengali", "Bangladesh and India"),
    (0x0446, Language::Punjabi_India, "pa-IN", "Punjabi", "India"),
    (0x0447, Language::Gujarati_India, "gu-IN", "Gujarati", "India"),
    (0x0448, Language::Odia_India, "or-IN", "Odia (formerly Oriya)", "India"),
    (0x0449, Language::Tamil_India, "ta-IN", "Tamil", "India"),
    (0x044A, Language::Telugu_India, "te-IN", "Telugu", "India"),
    (0x044B, Language::Kannada_India, "kn-IN", "Kannada", "India"),
    (0x044C, Language::Malayalam_India, "ml-IN", "Malayalam", "India"),
    (0x044D, Language::Assamese_India, "as-IN", "Assamese", "India"),
    (0x044E, Language::Marathi_India, "mr-IN", "Marathi", "India"),
    (0x044F, Language::Sanskrit_India, "sa-IN", "Sanskrit", "India"),
    (0x0450, Language::Mongolian_Cyrillic_Mongolia, "mn-Cyrl", "Mongolian (Cyrillic)", "Mongolia"),
    (0x0451, Language::Tibetan_PeoplesRepublicOfChina, "bo-CN", "Tibetan", "People's Republic of China"),
    (0x0452, Language::Welsh_UnitedKingdom, "cy-GB", "Welsh", "United Kingdom"),
    (0x0453, Language::Khmer_Cambodia, "km-KH", "Khmer", "Cambodia"),
    (0x0454, Language::Lao_LaoPDR, "lo-LA", "Lao", "Lao P.D.R."),
    (0x0456, Language::Galician_Galician, "gl-ES", "Galician", "Galician"),
    (0x0457, Language::Konkani_India, "kok-IN", "Konkani", "India"),
    (0x045A, Language::Syriac_Syria, "syr-SY", "Syriac", "Syria"),
    (0x045B, Language::Sinhala_SriLanka, "si-LK", "Sinhala", "Sri Lanka"),
    (0x045C, Language::Cherokee_Cherokee, "chr-Cher-US", "Cherokee", "Cherokee"),
    (0x045D, Language::Inuktitut_CanadianSyllabics_Canada, "iu-Cans-CA", "Inuktitut (Canadian Syllabics)", "Canada"),
    (0x045E, Language::Amharic_Ethiopia, "am-ET", "Amharic", "Ethiopia"),
    (0x0461, Language::Nepali_Nepal, "ne-NP", "Nepali", "Nepal"),
    (0x0462, Language::Frisian_Netherlands, "fy-NL", "Frisian", "Netherlands"),
    (0x0463, Language::Pashto_Afghanistan, "ps-AF", "Pashto", "Afghanistan"),
    (0x0464, Language::Filipino_Philippines, "fil-PH", "Filipino", "Philippines"),
    (0x0465, Language::Divehi_Maldives, "dv-MV", "Divehi", "Maldives"),
    (0x0468, Language::Hausa_Latin_Nigeria, "ha-Latn-NG", "Hausa (Latin)", "Nigeria"),
    (0x046A, Language::Yoruba_Nigeria, "yo-NG", "Yoruba", "Nigeria"),
    (0x046B, Language::Quechua_Bolivia, "quz-BO", "Quechua", "Bolivia"),
    (0x046C, Language::SesothoSaLeboa_SouthAfrica, "nso-ZA", "Sesotho sa Leboa", "South Africa"),
    (0x046D, Language::Bashkir_Russia, "ba-RU", "Bashkir", "Russia"),
    (0x046E, Language::Luxembourgish_Luxembourg, "lb-LU", "Luxembourgish", "Luxembourg"),
    (0x046F, Language::Greenlandic_Greenland, "kl-GL", "Greenlandic", "Greenland"),
    (0x0470, Language::Igbo_Nigeria, "ig-NG", "Igbo", "Nigeria"),
    (0x0473, Language::Tigrinya_Ethiopia, "ti-ET", "Tigrinya", "Ethiopia"),
    (0x0475, Language::Hawiian_UnitedStates, "haw-US", "Hawiian", "United States"),
    (0x0478, Language::Yi_PeoplesRepublicOfChina, "ii-CN", "Yi", "People's Republic of China"),
    (0x047A, Language::Mapudungun_Chile, "arn-CL", "Mapudungun", "Chile"),
    (0x047C, Language::Mohawk_Mohawk, "moh-CA", "Mohawk", "Mohawk"),
    (0x047E, Language::Breton_France, "br-FR", "Breton", "France"),
    (0x0480, Language::Uighur_PeoplesRepublicOfChina, "ug-CN", "Uighur", "People's Republic of China"),
    (0x0481, Language::Maori_NewZealand, "mi-NZ", "Maori", "New Zealand"),
    (0x0482, Language::Occitan_France, "oc-FR", "Occitan", "France"),
    (0x0483, Language::Corsican_France, "co-FR", "Corsican", "France"),
    (0x0484, Language::Alsatian_France, "gsw-FR", "Alsatian", "France"),
    (0x0485, Language::Yakut_Russia, "sah-RU", "Yakut", "Russia"),
    (0x0486, Language::Kiche_Guatemala, "qut-GT", "K'iche", "Guatemala"),
    (0x0487, Language::Kinyarwanda_Rwanda, "rw-RW", "Kinyarwanda", "Rwanda"),
    (0x0488, Language::Wolof_Senegal, "wo-SN", "Wolof", "Senegal"),
    (0x048C, Language::Dari_Afghanistan, "prs-AF", "Dari", "Afghanistan"),
    (0x0491, Language::ScottishGaelic_UnitedKingdom, "gd-GB", "Scottish Gaelic", "United Kingdom"),
    (0x0492, Language::CentralKurdish_Iraq, "ku-Arab-IQ", "Central Kurdish", "Iraq"),
    (0x0801, Language::Arabic_Iraq, "ar-IQ", "Arabic", "Iraq"),
    (0x0804, Language::Chinese_Simplified_PeoplesRepublicOfChina, "zh-Hans", "Chinese (Simplified)", "People's Republic of China"),
    (0x0807, Language::German_Switzerland, "de-CH", "German", "Switzerland"),
    (0x0809, Language::English_UnitedKingdom, "en-GB", "English", "United Kingdom"),
    (0x080A, Language::Spanish_Mexico, "es-MX", "Spanish", "Mexico"),
    (0x080C, Language::French_Belgium, "fr-BE", "French", "Belgium"),
    (0x0810, Language::Italian_Switzerland, "it-CH", "Italian", "Switzerland"),
    (0x0813, Language::Dutch_Belgium, "nl-BE", "Dutch", "Belgium"),
    (0x0814, Language::Norwegian_Nynorsk_Norway, "nn-NO", "Norwegian (Nynorsk)", "Norway"),
    (0x0816, Language::Portuguese_Portugal, "pt-PT", "Portuguese", "Portugal"),
    (0x081A, Language::Serbian_Latin_SerbiaAndMontenegro, "sr-Latn-CS", "Serbian (Latin)", "Serbia and Montenegro"),
    (0x081D, Language::Swedish_Finland, "sv-FI", "Swedish", "Finland"),
    (0x0820, Language::Urdu_India, "ur-IN", "Urdu", "India"),
    (0x082C, Language::Azeri_Cyrillic_Azerbaijan, "az-Cyrl-AZ", "Azeri (Cyrillic)", "Azerbaijan"),
    (0x082E, Language::LowerSorbian_Germany, "dsb-DE", "Lower Sorbian", "Germany"),
    (0x0832, Language::Setswana_Botswana, "tn-BW", "Setswana", "Botswana"),
    (0x083B, Language::Sami_Northern_Sweden, "se-SE", "Sami (Northern)", "Sweden"),
    (0x083C, Language::Irish_Ireland, "ga-IE", "Irish", "Ireland"),
    (0x083E, Language::Malay_BruneiDarussalam, "ms-BN", "Malay", "Brunei Darussalam"),
    (0x0843, Language::Uzbek_Cyrillic_Uzbekistan, "uz-Cyrl-UZ", "Uzbek (Cyrillic)", "Uzbekistan"),
    (0x0845, Language::Bengali_Bangladesh, "bn-BD", "Bengali", "Bangladesh"),
    (0x0846, Language::Punjabi_IslamicRepublicOfPakistan, "pa-Arab-PK", "Punjabi", "Islamic Republic of Pakistan"),
    (0x0849, Language::Tamil_SriLanka, "ta-LK", "Tamil", "SriLanka"),
    (0x0850, Language::Mongolian_Traditional_Mongolia, "mn-Mong-MN", "Mongolian (Traditional)", "Mongolia"),
    (0x0859, Language::Sindhi_IslamicRepublicOfPakistan, "sd-Arab-PK", "Sindhi", "Islamic Republic of Pakistan"),
    (0x085D, Language::Inuktitut_Latin_Canada, "iu-Latn-CA", "Inuktitut (Latin)", "Canada"),
    (0x085F, Language::Tamazight_Latin_Algeria, "tzm-Latn-DZ", "Tamazight (Latin)", "Algeria"),
    (0x086B, Language::Quechua_Ecuador, "quz-EC", "Quechua", "Ecuador"),
    (0x0873, Language::Tigrinya_Eritrea, "ti-ER", "Tigrinya", "Eritrea"),
    (0x0C01, Language::Arabic_Egypt, "ar-EG", "Arabic", "Egypt"),
    (0x0C04, Language::Chinese_HongKongSAR, "zh-Hant", "Chinese", "Hong Kong S.A.R."),
    (0x0C07, Language::German_Austria, "de-AT", "German", "Austria"),
    (0x0C09, Language::English_Australia, "en-AU", "English", "Australia"),
    (0x0C0A, Language::Spanish_ModernSort_Spain, "es-ES", "Spanish (Modern Sort)", "Spain"),
    (0x0C0C, Language::French_Canada, "fr-CA", "French", "Canada"),
    (0x0C1A, Language::Serbian_Cyrillic_SerbiaAndMontenegro, "sr-Cyrl-CS", "Serbian (Cyrillic)", "Serbia and Montenegro"),
    (0x0C3B, Language::Sami_Northern_Finland, "se-FI", "Sami (Northern)", "Finland"),
    (0x0C6B, Language::Quechua_Peru, "quz-PE", "Quechua", "Peru"),
    (0x1001, Language::Arabic_Libya, "ar-LY", "Arabic", "Libya"),
    (0x1004, Language::Chinese_Singapore, "zh-SG", "Chinese", "Singapore"),
    (0x1007, Language::German_Luxembourg, "de-LU", "German", "Luxembourg"),
    (0x1009, Language::English_Canada, "en-CA", "English", "Canada"),
    (0x100A, Language::Spanish_Guatemala, "es-GT", "Spanish", "Guatemala"),
    (0x100C, Language::French_Switzerland, "fr-CH", "French", "Switzerland"),
    (0x101A, Language::Croatian_Latin_BosniaAndHerzegovina, "hr-BA", "Croatian (Latin)", "Bosnia and Herzegovina"),
    (0x103B, Language::Sami_Lule_Norway, "smj-NO", "Sami (Lule)", "Norway"),
    (0x1401, Language::Arabic_Algeria, "ar-DZ", "Arabic", "Algeria"),
    (0x1404, Language::Chinese_MacaoSAR, "zh-MO", "Chinese", "Macao S.A.R."),
    (0x1407, Language::German_Liechtenstein, "de-LI", "German", "Liechtenstein"),
    (0x1409, Language::English_NewZealand, "en-NZ", "English", "New Zealand"),
    (0x140A, Language::Spanish_CostaRica, "es-CR", "Spanish", "Costa Rica"),
    (0x140c, Language::French_Luxembourg, "fr-LU", "French", "Luxembourg"),
    (0x141A, Language::Bosnian_Latin_BosniaAndHerzegovina, "bs-Latn-BA", "Bosnian (Latin)", "Bosnia and Herzegovina"),
    (0x143B, Language::Sami_Lule_Sweden, "smj-SE", "Sami (Lule)", "Sweden"),
    (0x105F, Language::CentralAtlasTamazight_Tifinagh_Morocco, "tzm-Tfng-MA", "Central Atlas Tamazight (Tifinagh)", "Morocco"),
    (0x1801, Language::Arabic_Morocco, "ar-MA", "Arabic", "Morocco"),
    (0x1809, Language::English_Ireland, "en-IE", "English", "Ireland"),
    (0x180A, Language::Spanish_Panama, "es-PA", "Spanish", "Panama"),
    (0x180C, Language::French_PrincipalityOfMonaco, "fr-MC", "French", "Principality of Monaco"),
    (0x181A, Language::Serbian_Latin_BosniaAndHerzegovina, "sr-Latn-BA", "Serbian (Latin)", "Bosnia and Herzegovina"),
    (0x183B, Language::Sami_Southern_Norway, "sma-NO", "Sami (Southern)", "Norway"),
    (0x1C01, Language::Arabic_Tunisia, "ar-TN", "Arabic", "Tunisia"),
    (0x1C09, Language::English_SouthAfrica, "en-ZA", "English", "South Africa"),
    (0x1C0A, Language::Spanish_DominicanRepublic, "es-DO", "Spanish", "Dominican Republic"),
    (0x1C1A, Language::Serbian_Cyrillic_BosniaAndHerzegovina, "sr-Cyrl-BA", "Serbian (Cyrillic)", "Bosnia and Herzegovina"),
    (0x1C3B, Language::Sami_Southern_Sweden, "sma-SE", "Sami (Southern)", "Sweden"),
    (0x2001, Language::Arabic_Oman, "ar-OM", "Arabic", "Oman"),
    (0x2009, Language::English_Jamaica, "en-JM", "English", "Jamaica"),
    (0x200A, Language::Spanish_Venezuela, "es-VE", "Spanish", "Venezuela"),
    (0x201A, Language::Bosnian_Cyrillic_BosniaAndHerzegovina, "bs-Cyrl-BA", "Bosnian (Cyrillic)", "Bosnia and Herzegovina"),
    (0x203B, Language::Sami_Skolt_Finland, "sms-FI", "Sami (Skolt)", "Finland"),
    (0x2401, Language::Arabic_Yemen, "ar-YE", "Arabic", "Yemen"),
    (0x2409, Language::English_Caribbean, "en-029", "English", "Caribbean"),
    (0x240A, Language::Spanish_Colombia, "es-CO", "Spanish", "Colombia"),
    (0x241A, Language::Serbian_Latin_Serbia, "sr-Latn-RS", "Serbian (Latin)", "Serbia"),
    (0x243B, Language::Sami_Inari_Finland, "smn-FI", "Sami (Inari)", "Finland"),
    (0x2801, Language::Arabic_Syria, "ar-SY", "Arabic", "Syria"),
    (0x2809, Language::English_Belize, "en-BZ", "English", "Belize"),
    (0x280A, Language::Spanish_Peru, "es-PE", "Spanish", "Peru"),
    (0x281A, Language::Serbian_Cyrillic_Serbia, "sr-Cyrl-RS", "Serbian (Cyrillic)", "Serbia"),
    (0x2C01, Language::Arabic_Jordan, "ar-JO", "Arabic", "Jordan"),
    (0x2C09, Language::English_TrinidadAndTobago, "en-TT", "English", "Trinidad and Tobago"),
    (0x2C0A, Language::Spanish_Argentina, "es-AR", "Spanish", "Argentina"),
    (0x2C1A, Language::Serbian_Latin_Montenegro, "sr-Latn-ME", "Serbian (Latin)", "Montenegro"),
    (0x3001, Language::Arabic_Lebanon, "ar-LB", "Arabic", "Lebanon"),
    (0x3009, Language::English_Zimbabwe, "en-ZW", "English", "Zimbabwe"),
    (0x300A, Language::Spanish_Ecuador, "es-EC", "Spanish", "Ecuador"),
    (0x301A, Language::Serbian_Cyrillic_Montenegro, "sr-Cyrl-ME", "Serbian (Cyrillic)", "Montenegro"),
    (0x3401, Language::Arabic_Kuwait, "ar-KW", "Arabic", "Kuwait"),
    (0x3409, Language::English_RepublicOfThePhilippines, "en-PH", "English", "Republic of the Philippines"),
    (0x340A, Language::Spanish_Chile, "es-CL", "Spanish", "Chile"),
    (0x3801, Language::Arabic_UAE, "ar-AE", "Arabic", "U.A.E."),
    (0x380A, Language::Spanish_Uruguay, "es-UY", "Spanish", "Uruguay"),
    (0x3C01, Language::Arabic_Bahrain, "ar-BH", "Arabic", "Bahrain"),
    (0x3C0A, Language::Spanish_Paraguay, "es-PY", "Spanish", "Paraguay"),
    (0x4001, Language::Arabic_Qatar, "ar-QA", "Arabic", "Qatar"),
    (0x4009, Language::English_India, "en-IN", "English", "India"),
    (0x400A, Language::Spanish_Bolivia, "es-BO", "Spanish", "Bolivia"),
    (0x4409, Language::English_Malaysia, "en-MY", "English", "Malaysia"),
    (0x440A, Language::Spanish_ElSalvador, "es-SV", "Spanish", "El Salvador"),
    (0x4809, Language::English_Singapore, "en-SG", "English", "Singapore"),
    (0x480A, Language::Spanish_Honduras, "es-HN", "Spanish", "Honduras"),
    (0x4C0A, Language::Spanish_Nicaragua, "es-NI", "Spanish", "Nicaragua"),
    (0x500A, Language::Spanish_PuertoRico, "es-PR", "Spanish", "Puerto Rico"),
    (0x540A, Language::Spanish_UnitedStates, "es-US", "Spanish", "United States"),
];

#[rustfmt::skip]
lazy_static! {
    // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f
    // Date: 2024-04-23, 16.0
    pub static ref LANG_TAG_PRIMARY_LANGUAGE: HashMap<&'static str, PrimaryLanguage> = HashMap::from_iter([
        ("aa", PrimaryLanguage::Afar),
        ("aa-DJ", PrimaryLanguage::Afar),
        ("aa-ER", PrimaryLanguage::Afar),
        ("aa-ET", PrimaryLanguage::Afar),
        ("af", PrimaryLanguage::Afrikaans),
        ("af-NA", PrimaryLanguage::Afrikaans),
        ("af-ZA", PrimaryLanguage::Afrikaans),
        ("agq", PrimaryLanguage::Aghem),
        ("agq-CM", PrimaryLanguage::Aghem),
        ("ak", PrimaryLanguage::Akan),
        ("ak-GH", PrimaryLanguage::Akan),
        ("sq", PrimaryLanguage::Albanian),
        ("sq-AL", PrimaryLanguage::Albanian),
        ("sq-MK", PrimaryLanguage::Albanian),
        ("gsw", PrimaryLanguage::Alsatian),
        ("gsw-FR", PrimaryLanguage::Alsatian),
        ("gsw-LI", PrimaryLanguage::Alsatian),
        ("gsw-CH", PrimaryLanguage::Alsatian),
        ("am", PrimaryLanguage::Amharic),
        ("am-ET", PrimaryLanguage::Amharic),
        ("ar", PrimaryLanguage::Arabic),
        ("ar-DZ", PrimaryLanguage::Arabic),
        ("ar-BH", PrimaryLanguage::Arabic),
        ("ar-TD", PrimaryLanguage::Arabic),
        ("ar-KM", PrimaryLanguage::Arabic),
        ("ar-DJ", PrimaryLanguage::Arabic),
        ("ar-EG", PrimaryLanguage::Arabic),
        ("ar-ER", PrimaryLanguage::Arabic),
        ("ar-IQ", PrimaryLanguage::Arabic),
        ("ar-IL", PrimaryLanguage::Arabic),
        ("ar-JO", PrimaryLanguage::Arabic),
        ("ar-KW", PrimaryLanguage::Arabic),
        ("ar-LB", PrimaryLanguage::Arabic),
        ("ar-LY", PrimaryLanguage::Arabic),
        ("ar-MR", PrimaryLanguage::Arabic),
        ("ar-MA", PrimaryLanguage::Arabic),
        ("ar-OM", PrimaryLanguage::Arabic),
        ("ar-PS", PrimaryLanguage::Arabic),
        ("ar-QA", PrimaryLanguage::Arabic),
        ("ar-SA", PrimaryLanguage::Arabic),
        ("ar-SO", PrimaryLanguage::Arabic),
        ("ar-SS", PrimaryLanguage::Arabic),
        ("ar-SD", PrimaryLanguage::Arabic),
        ("ar-SY", PrimaryLanguage::Arabic),
        ("ar-TN", PrimaryLanguage::Arabic),
        ("ar-AE", PrimaryLanguage::Arabic),
        ("ar-001", PrimaryLanguage::Arabic),
        ("ar-YE", PrimaryLanguage::Arabic),
        ("hy", PrimaryLanguage::Armenian),
        ("hy-AM", PrimaryLanguage::Armenian),
        ("as", PrimaryLanguage::Assamese),
        ("as-IN", PrimaryLanguage::Assamese),
        ("ast", PrimaryLanguage::Asturian),
        ("ast-ES", PrimaryLanguage::Asturian),
        ("asa", PrimaryLanguage::Asu),
        ("asa-TZ", PrimaryLanguage::Asu),
        ("az-Cyrl", PrimaryLanguage::Azerbaijani),
        ("az-Cyrl-AZ", PrimaryLanguage::Azerbaijani),
        ("az", PrimaryLanguage::Azerbaijani),
        ("az-Latn", PrimaryLanguage::Azerbaijani),
        ("az-Latn-AZ", PrimaryLanguage::Azerbaijani),
        ("ksf", PrimaryLanguage::Bafia),
        ("ksf-CM", PrimaryLanguage::Bafia),
        ("bm", PrimaryLanguage::Bamanankan),
        ("bm-Latn-ML", PrimaryLanguage::Bamanankan),
        ("bn", PrimaryLanguage::Bangla),
        ("bn-BD", PrimaryLanguage::Bangla),
        ("bn-IN", PrimaryLanguage::Bangla),
        ("bas", PrimaryLanguage::Basaa),
        ("bas-CM", PrimaryLanguage::Basaa),
        ("ba", PrimaryLanguage::Bashkir),
        ("ba-RU", PrimaryLanguage::Bashkir),
        ("eu", PrimaryLanguage::Basque),
        ("eu-ES", PrimaryLanguage::Basque),
        ("be", PrimaryLanguage::Belarusian),
        ("be-BY", PrimaryLanguage::Belarusian),
        ("bem", PrimaryLanguage::Bemba),
        ("bem-ZM", PrimaryLanguage::Bemba),
        ("bez", PrimaryLanguage::Bena),
        ("bez-TZ", PrimaryLanguage::Bena),
        ("bho", PrimaryLanguage::Bhojpuri),
        ("bho-Deva", PrimaryLanguage::Bhojpuri),
        ("bho-Deva-IN", PrimaryLanguage::Bhojpuri),
        ("byn", PrimaryLanguage::Blin),
        ("byn-ER", PrimaryLanguage::Blin),
        ("brx", PrimaryLanguage::Bodo),
        ("brx-IN", PrimaryLanguage::Bodo),
        ("bs-Cyrl", PrimaryLanguage::Bosnian),
        ("bs-Cyrl-BA", PrimaryLanguage::Bosnian),
        ("bs-Latn", PrimaryLanguage::Bosnian),
        ("bs", PrimaryLanguage::Bosnian),
        ("bs-Latn-BA", PrimaryLanguage::Bosnian),
        ("br", PrimaryLanguage::Breton),
        ("br-FR", PrimaryLanguage::Breton),
        ("bg", PrimaryLanguage::Bulgarian),
        ("bg-BG", PrimaryLanguage::Bulgarian),
        ("my", PrimaryLanguage::Burmese),
        ("my-MM", PrimaryLanguage::Burmese),
        ("ca", PrimaryLanguage::Catalan),
        ("ca-AD", PrimaryLanguage::Catalan),
        ("ca-FR", PrimaryLanguage::Catalan),
        ("ca-IT", PrimaryLanguage::Catalan),
        ("ca-ES", PrimaryLanguage::Catalan),
        ("ceb", PrimaryLanguage::Cebuano),
        ("ceb-Latn", PrimaryLanguage::Cebuan),
        ("ceb-Latn-PH", PrimaryLanguage::Cebuan),
        ("tzm-Arab-MA", PrimaryLanguage::CentralAtlasTamazight),
        ("tzm-Latn-MA", PrimaryLanguage::CentralAtlasTamazight),
        ("ku", PrimaryLanguage::CentralKurdish),
        ("ku-Arab", PrimaryLanguage::CentralKurdish),
        ("ku-Arab-IQ", PrimaryLanguage::CentralKurdish),
        ("ccp", PrimaryLanguage::Chakma),
        ("ccp-Cakm", PrimaryLanguage::Chakma),
        ("ccp-Cakm-BD", PrimaryLanguage::Chakma),
        ("ccp-Cakm-IN", PrimaryLanguage::Chakma),
        ("ce-RU", PrimaryLanguage::Chechen),
        ("chr", PrimaryLanguage::Cherokee),
        ("chr-Cher", PrimaryLanguage::Cherokee),
        ("chr-Cher-US", PrimaryLanguage::Cherokee),
        ("cgg", PrimaryLanguage::Chiga),
        ("cgg-UG", PrimaryLanguage::Chiga),
        ("zh-Hans", PrimaryLanguage::Chinese),
        ("zh", PrimaryLanguage::Chinese),
        ("zh-CN", PrimaryLanguage::Chinese),
        ("zh-SG", PrimaryLanguage::Chinese),
        ("zh-Hant", PrimaryLanguage::Chinese),
        ("zh-HK", PrimaryLanguage::Chinese),
        ("zh-MO", PrimaryLanguage::Chinese),
        ("zh-TW", PrimaryLanguage::Chinese),
        ("cu-RU", PrimaryLanguage::ChurchSlavic),
        ("cv", PrimaryLanguage::Chuvash),
        ("cv-Cyrl", PrimaryLanguage::Chuvash),
        ("cv-Cyrl-RU", PrimaryLanguage::Chuvash),
        ("swc", PrimaryLanguage::CongoSwahili),
        ("swc-CD", PrimaryLanguage::CongoSwahili),
        ("kw", PrimaryLanguage::Cornish),
        ("kw-GB", PrimaryLanguage::Cornish),
        ("co", PrimaryLanguage::Corsican),
        ("co-FR", PrimaryLanguage::Corsican),
        ("hr", PrimaryLanguage::Croatian),
        ("hr-HR", PrimaryLanguage::Croatian),
        ("hr-BA", PrimaryLanguage::Croatian),
        ("cs", PrimaryLanguage::Czech),
        ("cs-CZ", PrimaryLanguage::Czech),
        ("da", PrimaryLanguage::Danish),
        ("da-DK", PrimaryLanguage::Danish),
        ("da-GL", PrimaryLanguage::Danish),
        ("prs", PrimaryLanguage::Dari),
        ("prs-AF", PrimaryLanguage::Dari),
        ("dv", PrimaryLanguage::Divehi),
        ("dv-MV", PrimaryLanguage::Divehi),
        ("dua", PrimaryLanguage::Duala),
        ("dua-CM", PrimaryLanguage::Duala),
        ("nl", PrimaryLanguage::Dutch),
        ("nl-AW", PrimaryLanguage::Dutch),
        ("nl-BE", PrimaryLanguage::Dutch),
        ("nl-BQ", PrimaryLanguage::Dutch),
        ("nl-CW", PrimaryLanguage::Dutch),
        ("nl-NL", PrimaryLanguage::Dutch),
        ("nl-SX", PrimaryLanguage::Dutch),
        ("nl-SR", PrimaryLanguage::Dutch),
        ("dz", PrimaryLanguage::Dzongkha),
        ("dz-BT", PrimaryLanguage::Dzongkha),
        ("ebu", PrimaryLanguage::Embu),
        ("ebu-KE", PrimaryLanguage::Embu),
        ("en", PrimaryLanguage::English),
        ("en-AS", PrimaryLanguage::English),
        ("en-AI", PrimaryLanguage::English),
        ("en-AG", PrimaryLanguage::English),
        ("en-AU", PrimaryLanguage::English),
        ("en-AT", PrimaryLanguage::English),
        ("en-BS", PrimaryLanguage::English),
        ("en-BB", PrimaryLanguage::English),
        ("en-BE", PrimaryLanguage::English),
        ("en-BZ", PrimaryLanguage::English),
        ("en-BM", PrimaryLanguage::English),
        ("en-BW", PrimaryLanguage::English),
        ("en-IO", PrimaryLanguage::English),
        ("en-VG", PrimaryLanguage::English),
        ("en-BI", PrimaryLanguage::English),
        ("en-CM", PrimaryLanguage::English),
        ("en-CA", PrimaryLanguage::English),
        ("en-029", PrimaryLanguage::English),
        ("en-KY", PrimaryLanguage::English),
        ("en-CX", PrimaryLanguage::English),
        ("en-CC", PrimaryLanguage::English),
        ("en-CK", PrimaryLanguage::English),
        ("en-CY", PrimaryLanguage::English),
        ("en-DK", PrimaryLanguage::English),
        ("en-DM", PrimaryLanguage::English),
        ("en-ER", PrimaryLanguage::English),
        ("en-150", PrimaryLanguage::English),
        ("en-FK", PrimaryLanguage::English),
        ("en-FI", PrimaryLanguage::English),
        ("en-FJ", PrimaryLanguage::English),
        ("en-GM", PrimaryLanguage::English),
        ("en-DE", PrimaryLanguage::English),
        ("en-GH", PrimaryLanguage::English),
        ("en-GI", PrimaryLanguage::English),
        ("en-GD", PrimaryLanguage::English),
        ("en-GU", PrimaryLanguage::English),
        ("en-GG", PrimaryLanguage::English),
        ("en-GY", PrimaryLanguage::English),
        ("en-HK", PrimaryLanguage::English),
        ("en-IN", PrimaryLanguage::English),
        ("en-IE", PrimaryLanguage::English),
        ("en-IM", PrimaryLanguage::English),
        ("en-IL", PrimaryLanguage::English),
        ("en-JM", PrimaryLanguage::English),
        ("en-JE", PrimaryLanguage::English),
        ("en-KE", PrimaryLanguage::English),
        ("en-KI", PrimaryLanguage::English),
        ("en-LS", PrimaryLanguage::English),
        ("en-LR", PrimaryLanguage::English),
        ("en-MO", PrimaryLanguage::English),
        ("en-MG", PrimaryLanguage::English),
        ("en-MW", PrimaryLanguage::English),
        ("en-MY", PrimaryLanguage::English),
        ("en-MV", PrimaryLanguage::English),
        ("en-MT", PrimaryLanguage::English),
        ("en-MH", PrimaryLanguage::English),
        ("en-MU", PrimaryLanguage::English),
        ("en-FM", PrimaryLanguage::English),
        ("en-MS", PrimaryLanguage::English),
        ("en-NA", PrimaryLanguage::English),
        ("en-NR", PrimaryLanguage::English),
        ("en-NL", PrimaryLanguage::English),
        ("en-NZ", PrimaryLanguage::English),
        ("en-NG", PrimaryLanguage::English),
        ("en-NU", PrimaryLanguage::English),
        ("en-NF", PrimaryLanguage::English),
        ("en-MP", PrimaryLanguage::English),
        ("en-PK", PrimaryLanguage::English),
        ("en-PW", PrimaryLanguage::English),
        ("en-PG", PrimaryLanguage::English),
        ("en-PN", PrimaryLanguage::English),
        ("en-PR", PrimaryLanguage::English),
        ("en-PH", PrimaryLanguage::English),
        ("en-RW", PrimaryLanguage::English),
        ("en-KN", PrimaryLanguage::English),
        ("en-LC", PrimaryLanguage::English),
        ("en-VC", PrimaryLanguage::English),
        ("en-WS", PrimaryLanguage::English),
        ("en-SC", PrimaryLanguage::English),
        ("en-SL", PrimaryLanguage::English),
        ("en-SG", PrimaryLanguage::English),
        ("en-SX", PrimaryLanguage::English),
        ("en-SI", PrimaryLanguage::English),
        ("en-SB", PrimaryLanguage::English),
        ("en-ZA", PrimaryLanguage::English),
        ("en-SS", PrimaryLanguage::English),
        ("en-SH", PrimaryLanguage::English),
        ("en-SD", PrimaryLanguage::English),
        ("en-SZ", PrimaryLanguage::English),
        ("en-SE", PrimaryLanguage::English),
        ("en-CH", PrimaryLanguage::English),
        ("en-TZ", PrimaryLanguage::English),
        ("en-TK", PrimaryLanguage::English),
        ("en-TO", PrimaryLanguage::English),
        ("en-TT", PrimaryLanguage::English),
        ("en-TC", PrimaryLanguage::English),
        ("en-TV", PrimaryLanguage::English),
        ("en-UG", PrimaryLanguage::English),
        ("en-AE", PrimaryLanguage::English),
        ("en-GB", PrimaryLanguage::English),
        ("en-US", PrimaryLanguage::English),
        ("en-UM", PrimaryLanguage::English),
        ("en-VI", PrimaryLanguage::English),
        ("en-VU", PrimaryLanguage::English),
        ("en-001", PrimaryLanguage::English),
        ("en-ZM", PrimaryLanguage::English),
        ("en-ZW", PrimaryLanguage::English),
        ("eo", PrimaryLanguage::Esperanto),
        ("eo-001", PrimaryLanguage::Esperanto),
        ("et", PrimaryLanguage::Estonian),
        ("et-EE", PrimaryLanguage::Estonian),
        ("ee", PrimaryLanguage::Ewe),
        ("ee-GH", PrimaryLanguage::Ewe),
        ("ee-TG", PrimaryLanguage::Ewe),
        ("ewo", PrimaryLanguage::Ewondo),
        ("ewo-CM", PrimaryLanguage::Ewondo),
        ("fo", PrimaryLanguage::Faroese),
        ("fo-DK", PrimaryLanguage::Faroese),
        ("fo-FO", PrimaryLanguage::Faroese),
        ("fil", PrimaryLanguage::Filipino),
        ("fil-PH", PrimaryLanguage::Filipino),
        ("fi", PrimaryLanguage::Finnish),
        ("fi-FI", PrimaryLanguage::Finnish),
        ("fr", PrimaryLanguage::French),
        ("fr-DZ", PrimaryLanguage::French),
        ("fr-BE", PrimaryLanguage::French),
        ("fr-BJ", PrimaryLanguage::French),
        ("fr-BF", PrimaryLanguage::French),
        ("fr-BI", PrimaryLanguage::French),
        ("fr-CM", PrimaryLanguage::French),
        ("fr-CA", PrimaryLanguage::French),
        ("fr-029", PrimaryLanguage::French),
        ("fr-CF", PrimaryLanguage::French),
        ("fr-TD", PrimaryLanguage::French),
        ("fr-KM", PrimaryLanguage::French),
        ("fr-CG", PrimaryLanguage::French),
        ("fr-CD", PrimaryLanguage::French),
        ("fr-CI", PrimaryLanguage::French),
        ("fr-DJ", PrimaryLanguage::French),
        ("fr-GQ", PrimaryLanguage::French),
        ("fr-FR", PrimaryLanguage::French),
        ("fr-GF", PrimaryLanguage::French),
        ("fr-PF", PrimaryLanguage::French),
        ("fr-GA", PrimaryLanguage::French),
        ("fr-GP", PrimaryLanguage::French),
        ("fr-GN", PrimaryLanguage::French),
        ("fr-HT", PrimaryLanguage::French),
        ("fr-LU", PrimaryLanguage::French),
        ("fr-MG", PrimaryLanguage::French),
        ("fr-ML", PrimaryLanguage::French),
        ("fr-MQ", PrimaryLanguage::French),
        ("fr-MR", PrimaryLanguage::French),
        ("fr-MU", PrimaryLanguage::French),
        ("fr-YT", PrimaryLanguage::French),
        ("fr-MA", PrimaryLanguage::French),
        ("fr-NC", PrimaryLanguage::French),
        ("fr-NE", PrimaryLanguage::French),
        ("fr-MC", PrimaryLanguage::French),
        ("fr-RE", PrimaryLanguage::French),
        ("fr-RW", PrimaryLanguage::French),
        ("fr-BL", PrimaryLanguage::French),
        ("fr-MF", PrimaryLanguage::French),
        ("fr-PM", PrimaryLanguage::French),
        ("fr-SN", PrimaryLanguage::French),
        ("fr-SC", PrimaryLanguage::French),
        ("fr-CH", PrimaryLanguage::French),
        ("fr-SY", PrimaryLanguage::French),
        ("fr-TG", PrimaryLanguage::French),
        ("fr-TN", PrimaryLanguage::French),
        ("fr-VU", PrimaryLanguage::French),
        ("fr-WF", PrimaryLanguage::French),
        ("fy", PrimaryLanguage::Frisian),
        ("fy-NL", PrimaryLanguage::Frisian),
        ("fur", PrimaryLanguage::Friulian),
        ("fur-IT", PrimaryLanguage::Friulian),
        ("ff", PrimaryLanguage::Fulah),
        ("ff-Latn", PrimaryLanguage::Fulah),
        ("ff-Latn-BF", PrimaryLanguage::Fulah),
        ("ff-CM", PrimaryLanguage::Fulah),
        ("ff-Latn-CM", PrimaryLanguage::Fulah),
        ("ff-Latn-GM", PrimaryLanguage::Fulah),
        ("ff-Latn-GH", PrimaryLanguage::Fulah),
        ("ff-GN", PrimaryLanguage::Fulah),
        ("ff-Latn-GN", PrimaryLanguage::Fulah),
        ("ff-Latn-GW", PrimaryLanguage::Fulah),
        ("ff-Latn-LR", PrimaryLanguage::Fulah),
        ("ff-MR", PrimaryLanguage::Fulah),
        ("ff-Latn-MR", PrimaryLanguage::Fulah),
        ("ff-Latn-NE", PrimaryLanguage::Fulah),
        ("ff-NG", PrimaryLanguage::Fulah),
        ("ff-Latn-NG", PrimaryLanguage::Fulah),
        ("ff-Latn-SN", PrimaryLanguage::Fulah),
        ("ff-Latn-SL", PrimaryLanguage::Fulah),
        ("gl", PrimaryLanguage::Galician),
        ("gl-ES", PrimaryLanguage::Galician),
        ("lg", PrimaryLanguage::Ganda),
        ("lg-UG", PrimaryLanguage::Ganda),
        ("ka", PrimaryLanguage::Georgian),
        ("ka-GE", PrimaryLanguage::Georgian),
        ("de", PrimaryLanguage::German),
        ("de-AT", PrimaryLanguage::German),
        ("de-BE", PrimaryLanguage::German),
        ("de-DE", PrimaryLanguage::German),
        ("de-IT", PrimaryLanguage::German),
        ("de-LI", PrimaryLanguage::German),
        ("de-LU", PrimaryLanguage::German),
        ("de-CH", PrimaryLanguage::German),
        ("el", PrimaryLanguage::Greek),
        ("el-CY", PrimaryLanguage::Greek),
        ("el-GR", PrimaryLanguage::Greek),
        ("kl", PrimaryLanguage::Greenlandic),
        ("kl-GL", PrimaryLanguage::Greenlandic),
        ("gn", PrimaryLanguage::Guarani),
        ("gn-PY", PrimaryLanguage::Guarani),
        ("gu", PrimaryLanguage::Gujarati),
        ("gu-IN", PrimaryLanguage::Gujarati),
        ("guz", PrimaryLanguage::Gusii),
        ("guz-KE", PrimaryLanguage::Gusii),
        ("bgc", PrimaryLanguage::Haryanvi),
        ("bgc-Deva", PrimaryLanguage::Haryanvi),
        ("bgc-Deva-IN", PrimaryLanguage::Haryanvi),
        ("ha", PrimaryLanguage::Hausa),
        ("ha-Latn", PrimaryLanguage::Hausa),
        ("ha-Latn-GH", PrimaryLanguage::Hausa),
        ("ha-Latn-NE", PrimaryLanguage::Hausa),
        ("ha-Latn-NG", PrimaryLanguage::Hausa),
        ("haw", PrimaryLanguage::Hawaiian),
        ("haw-US", PrimaryLanguage::Hawaiian),
        ("he", PrimaryLanguage::Hebrew),
        ("he-IL", PrimaryLanguage::Hebrew),
        ("hi", PrimaryLanguage::Hindi),
        ("hi-IN", PrimaryLanguage::Hindi),
        ("hi-Latn", PrimaryLanguage::Hindi),
        ("hi-Latn-IN", PrimaryLanguage::Hindi),
        ("hu", PrimaryLanguage::Hungarian),
        ("hu-HU", PrimaryLanguage::Hungarian),
        ("is", PrimaryLanguage::Icelandic),
        ("is-IS", PrimaryLanguage::Icelandic),
        ("ig", PrimaryLanguage::Igbo),
        ("ig-NG", PrimaryLanguage::Igbo),
        ("id", PrimaryLanguage::Indonesian),
        ("id-ID", PrimaryLanguage::Indonesian),
        ("ia", PrimaryLanguage::Interlingua),
        ("ia-FR", PrimaryLanguage::Interlingua),
        ("ia-001", PrimaryLanguage::Interlingua),
        ("iu", PrimaryLanguage::Inuktitut),
        ("iu-Latn", PrimaryLanguage::Inuktitut),
        ("iu-Latn-CA", PrimaryLanguage::Inuktitut),
        ("iu-Cans", PrimaryLanguage::Inuktitut),
        ("iu-Cans-CA", PrimaryLanguage::Inuktitut),
        ("ga", PrimaryLanguage::Irish),
        ("ga-IE", PrimaryLanguage::Irish),
        ("it", PrimaryLanguage::Italian),
        ("it-IT", PrimaryLanguage::Italian),
        ("it-SM", PrimaryLanguage::Italian),
        ("it-CH", PrimaryLanguage::Italian),
        ("it-VA", PrimaryLanguage::Italian),
        ("ja", PrimaryLanguage::Japanese),
        ("ja-JP", PrimaryLanguage::Japanese),
        ("jv", PrimaryLanguage::Javanese),
        ("jv-Latn", PrimaryLanguage::Javanese),
        ("jv-Latn-ID", PrimaryLanguage::Javanese),
        ("dyo", PrimaryLanguage::JolaFonyi),
        ("dyo-SN", PrimaryLanguage::JolaFonyi),
        ("kea", PrimaryLanguage::Kabuverdianu),
        ("kea-CV", PrimaryLanguage::Kabuverdianu),
        ("kab", PrimaryLanguage::Kabyle),
        ("kab-DZ", PrimaryLanguage::Kabyle),
        ("kgp", PrimaryLanguage::Kaingang),
        ("kgp-Latn", PrimaryLanguage::Kaingang),
        ("kgp-Latn-BR", PrimaryLanguage::Kaingang),
        ("kkj", PrimaryLanguage::Kako),
        ("kkj-CM", PrimaryLanguage::Kako),
        ("kln", PrimaryLanguage::Kalenjin),
        ("kln-KE", PrimaryLanguage::Kalenjin),
        ("kam", PrimaryLanguage::Kamba),
        ("kam-KE", PrimaryLanguage::Kamba),
        ("kn", PrimaryLanguage::Kannada),
        ("kn-IN", PrimaryLanguage::Kannada),
        ("kr-Latn-NG", PrimaryLanguage::Kanuri),
        ("ks", PrimaryLanguage::Kashmiri),
        ("ks-Arab", PrimaryLanguage::Kashmiri),
        ("ks-Arab-IN", PrimaryLanguage::Kashmiri),
        ("ks-Deva-IN", PrimaryLanguage::Kashmiri),
        ("kk", PrimaryLanguage::Kazakh),
        ("kk-KZ", PrimaryLanguage::Kazakh),
        ("km", PrimaryLanguage::Khmer),
        ("km-KH", PrimaryLanguage::Khmer),
        ("quc", PrimaryLanguage::Kiche),
        ("quc-Latn-GT", PrimaryLanguage::Kiche),
        ("ki", PrimaryLanguage::Kikuyu),
        ("ki-KE", PrimaryLanguage::Kikuyu),
        ("rw", PrimaryLanguage::Kinyarwanda),
        ("rw-RW", PrimaryLanguage::Kinyarwanda),
        ("sw", PrimaryLanguage::Kiswahili),
        ("sw-KE", PrimaryLanguage::Kiswahili),
        ("sw-TZ", PrimaryLanguage::Kiswahili),
        ("sw-UG", PrimaryLanguage::Kiswahili),
        ("kok", PrimaryLanguage::Konkani),
        ("kok-IN", PrimaryLanguage::Konkani),
        ("ko", PrimaryLanguage::Korean),
        ("ko-KR", PrimaryLanguage::Korean),
        ("ko-KP", PrimaryLanguage::Korean),
        ("khq", PrimaryLanguage::KoyraChiini),
        ("khq-ML", PrimaryLanguage::KoyraChiini),
        ("ses", PrimaryLanguage::KoyraboroSenni),
        ("ses-ML", PrimaryLanguage::KoyraboroSenni),
        ("nmg", PrimaryLanguage::Kwasio),
        ("nmg-CM", PrimaryLanguage::Kwasio),
        ("ky", PrimaryLanguage::Kyrgyz),
        ("ky-KG", PrimaryLanguage::Kyrgyz),
        ("ku-Arab-IR", PrimaryLanguage::Kurdish),
        ("lkt", PrimaryLanguage::Lakota),
        ("lkt-US", PrimaryLanguage::Lakota),
        ("lag", PrimaryLanguage::Langi),
        ("lag-TZ", PrimaryLanguage::Langi),
        ("lo", PrimaryLanguage::Lao),
        ("lo-LA", PrimaryLanguage::Lao),
        ("la-VA", PrimaryLanguage::Latin),
        ("lv", PrimaryLanguage::Latvian),
        ("lv-LV", PrimaryLanguage::Latvian),
        ("ln", PrimaryLanguage::Lingala),
        ("ln-AO", PrimaryLanguage::Lingala),
        ("ln-CF", PrimaryLanguage::Lingala),
        ("ln-CG", PrimaryLanguage::Lingala),
        ("ln-CD", PrimaryLanguage::Lingala),
        ("lt", PrimaryLanguage::Lithuanian),
        ("lt-LT", PrimaryLanguage::Lithuanian),
        ("nds", PrimaryLanguage::LowGerman),
        ("nds-DE", PrimaryLanguage::LowGerman ),
        ("nds-NL", PrimaryLanguage::LowGerman),
        ("dsb", PrimaryLanguage::LowerSorbian),
        ("dsb-DE", PrimaryLanguage::LowerSorbian),
        ("lu", PrimaryLanguage::LubaKatanga),
        ("lu-CD", PrimaryLanguage::LubaKatanga),
        ("luo", PrimaryLanguage::Luo),
        ("luo-KE", PrimaryLanguage::Luo),
        ("lb", PrimaryLanguage::Luxembourgish),
        ("lb-LU", PrimaryLanguage::Luxembourgish),
        ("luy", PrimaryLanguage::Luyia),
        ("luy-KE", PrimaryLanguage::Luyia),
        ("mk", PrimaryLanguage::Macedonian),
        ("mk-MK", PrimaryLanguage::Macedonian),
        ("jmc", PrimaryLanguage::Machame),
        ("jmc-TZ", PrimaryLanguage::Machame),
        ("mgh", PrimaryLanguage::MakhuwaMeetto),
        ("mgh-MZ", PrimaryLanguage::MakhuwaMeetto),
        ("kde", PrimaryLanguage::Makonde),
        ("kde-TZ", PrimaryLanguage::Makonde),
        ("mg", PrimaryLanguage::Malagasy),
        ("mg-MG", PrimaryLanguage::Malagasy),
        ("ms", PrimaryLanguage::Malay),
        ("ms-Arab", PrimaryLanguage::Malay),
        ("ms-BN", PrimaryLanguage::Malay),
        ("ms-Latn", PrimaryLanguage::Malay),
        ("ms-MY", PrimaryLanguage::Malay),
        ("ml", PrimaryLanguage::Malayalam),
        ("ml-IN", PrimaryLanguage::Malayalam),
        ("mt", PrimaryLanguage::Maltese),
        ("mt-MT", PrimaryLanguage::Maltese),
        ("gv", PrimaryLanguage::Manx),
        ("gv-IM", PrimaryLanguage::Manx),
        ("mi", PrimaryLanguage::Maori),
        ("mi-NZ", PrimaryLanguage::Maori),
        ("arn", PrimaryLanguage::Mapudungun),
        ("arn-CL", PrimaryLanguage::Mapudungun),
        ("mr", PrimaryLanguage::Marathi),
        ("mr-IN", PrimaryLanguage::Marathi),
        ("mas", PrimaryLanguage::Masai),
        ("mas-KE", PrimaryLanguage::Masai),
        ("mas-TZ", PrimaryLanguage::Masai),
        ("mzn-IR", PrimaryLanguage::Mazanderani),
        ("mer", PrimaryLanguage::Meru),
        ("mer-KE", PrimaryLanguage::Meru),
        ("mgo", PrimaryLanguage::Meta),
        ("mgo-CM", PrimaryLanguage::Meta),
        ("moh", PrimaryLanguage::Mohawk),
        ("moh-CA", PrimaryLanguage::Mohawk),
        ("mn", PrimaryLanguage::Mongolian),
        ("mn-Cyrl", PrimaryLanguage::Mongolian),
        ("mn-MN", PrimaryLanguage::Mongolian),
        ("mn-Mong", PrimaryLanguage::Mongolian),
        ("mn-Mong-CN", PrimaryLanguage::Mongolian),
        ("mn-Mong-MN", PrimaryLanguage::Mongolian),
        ("mfe", PrimaryLanguage::Morisyen),
        ("mfe-MU", PrimaryLanguage::Morisyen),
        ("mua", PrimaryLanguage::Mundang),
        ("mua-CM", PrimaryLanguage::Mundang),
        ("nqo", PrimaryLanguage::Nko),
        ("nqo-GN", PrimaryLanguage::Nko),
        ("naq", PrimaryLanguage::Nama),
        ("naq-NA", PrimaryLanguage::Nama),
        ("ne", PrimaryLanguage::Nepali),
        ("ne-IN", PrimaryLanguage::Nepali),
        ("ne-NP", PrimaryLanguage::Nepali),
        ("nnh", PrimaryLanguage::Ngiemboon),
        ("nnh-CM", PrimaryLanguage::Ngiemboon),
        ("jgo", PrimaryLanguage::Ngomba),
        ("jgo-CM", PrimaryLanguage::Ngomba),
        ("yrl", PrimaryLanguage::Nheengatu),
        ("yrl-Latn", PrimaryLanguage::Nheengatu),
        ("yrl-Latn-BR", PrimaryLanguage::Nheengatu),
        ("yrl-Latn-CO", PrimaryLanguage::Nheengatu),
        ("yrl-Latn-VE", PrimaryLanguage::Nheengatu),
        ("lrc-IQ", PrimaryLanguage::NorthernLuri),
        ("lrc-IR", PrimaryLanguage::NorthernLuri),
        ("nd", PrimaryLanguage::NorthNdebele),
        ("nd-ZW", PrimaryLanguage::NorthNdebele),
        ("no", PrimaryLanguage::Norwegian),
        ("nb", PrimaryLanguage::Norwegian),
        ("nb-NO", PrimaryLanguage::Norwegian),
        ("nn", PrimaryLanguage::Norwegian),
        ("nn-NO", PrimaryLanguage::Norwegian),
        ("nb-SJ", PrimaryLanguage::NorwegianBokml),
        ("nus", PrimaryLanguage::Nuer),
        ("nus-SD", PrimaryLanguage::Nuer),
        ("nus-SS", PrimaryLanguage::Nuer),
        ("nyn", PrimaryLanguage::Nyankole),
        ("nyn-UG", PrimaryLanguage::Nyankole),
        ("oc", PrimaryLanguage::Occitan),
        ("oc-FR", PrimaryLanguage::Occitan),
        ("oc-ES", PrimaryLanguage::Occitan),
        ("or", PrimaryLanguage::Odia),
        ("or-IN", PrimaryLanguage::Odia),
        ("om", PrimaryLanguage::Oromo),
        ("om-ET", PrimaryLanguage::Oromo),
        ("om-KE", PrimaryLanguage::Oromo),
        ("os", PrimaryLanguage::Ossetian),
        ("os-GE", PrimaryLanguage::Ossetian),
        ("os-RU", PrimaryLanguage::Ossetian),
        ("ps", PrimaryLanguage::Pashto),
        ("ps-AF", PrimaryLanguage::Pashto),
        ("ps-PK", PrimaryLanguage::Pashto),
        ("fa", PrimaryLanguage::Persian),
        ("fa-AF", PrimaryLanguage::Persian),
        ("fa-IR", PrimaryLanguage::Persian),
        ("pl", PrimaryLanguage::Polish),
        ("pl-PL", PrimaryLanguage::Polish),
        ("pt", PrimaryLanguage::Portuguese),
        ("pt-AO", PrimaryLanguage::Portuguese),
        ("pt-BR", PrimaryLanguage::Portuguese),
        ("pt-CV", PrimaryLanguage::Portuguese),
        ("pt-GQ", PrimaryLanguage::Portuguese),
        ("pt-GW", PrimaryLanguage::Portuguese),
        ("pt-LU", PrimaryLanguage::Portuguese),
        ("pt-MO", PrimaryLanguage::Portuguese),
        ("pt-MZ", PrimaryLanguage::Portuguese),
        ("pt-PT", PrimaryLanguage::Portuguese),
        ("pt-ST", PrimaryLanguage::Portuguese),
        ("pt-CH", PrimaryLanguage::Portuguese),
        ("pt-TL", PrimaryLanguage::Portuguese),
        ("prg-001", PrimaryLanguage::Prussian),
        ("qps-ploca", PrimaryLanguage::PseudoLanguage),
        ("qps-ploc", PrimaryLanguage::PseudoLanguage),
        ("qps-plocm", PrimaryLanguage::PseudoLanguage),
        ("pa", PrimaryLanguage::Punjabi),
        ("pa-Arab", PrimaryLanguage::Punjabi),
        ("pa-IN", PrimaryLanguage::Punjabi),
        ("pa-Arab-PK", PrimaryLanguage::Punjabi),
        ("quz", PrimaryLanguage::Quechua),
        ("quz-BO", PrimaryLanguage::Quechua),
        ("quz-EC", PrimaryLanguage::Quechua),
        ("quz-PE", PrimaryLanguage::Quechua),
        ("raj", PrimaryLanguage::Rajasthani),
        ("raj-Deva", PrimaryLanguage::Rajasthani),
        ("raj-Deva-IN", PrimaryLanguage::Rajasthani),
        ("ksh", PrimaryLanguage::Ripuarian),
        ("ksh-DE", PrimaryLanguage::Ripuarian),
        ("ro", PrimaryLanguage::Romanian),
        ("ro-MD", PrimaryLanguage::Romanian),
        ("ro-RO", PrimaryLanguage::Romanian),
        ("rm", PrimaryLanguage::Romansh),
        ("rm-CH", PrimaryLanguage::Romansh),
        ("rof", PrimaryLanguage::Rombo),
        ("rof-TZ", PrimaryLanguage::Rombo),
        ("rn", PrimaryLanguage::Rundi),
        ("rn-BI", PrimaryLanguage::Rundi),
        ("ru", PrimaryLanguage::Russian),
        ("ru-BY", PrimaryLanguage::Russian),
        ("ru-KZ", PrimaryLanguage::Russian),
        ("ru-KG", PrimaryLanguage::Russian),
        ("ru-MD", PrimaryLanguage::Russian),
        ("ru-RU", PrimaryLanguage::Russian),
        ("ru-UA", PrimaryLanguage::Russian),
        ("rwk", PrimaryLanguage::Rwa),
        ("rwk-TZ", PrimaryLanguage::Rwa),
        ("ssy", PrimaryLanguage::Saho),
        ("ssy-ER", PrimaryLanguage::Saho),
        ("sah", PrimaryLanguage::Sakha),
        ("sah-RU", PrimaryLanguage::Sakha),
        ("saq", PrimaryLanguage::Samburu),
        ("saq-KE", PrimaryLanguage::Samburu),
        ("smn", PrimaryLanguage::Sami),
        ("smn-FI", PrimaryLanguage::Sami),
        ("smj", PrimaryLanguage::Sami),
        ("smj-NO", PrimaryLanguage::Sami),
        ("smj-SE", PrimaryLanguage::Sami),
        ("se", PrimaryLanguage::Sami),
        ("se-FI", PrimaryLanguage::Sami),
        ("se-NO", PrimaryLanguage::Sami),
        ("se-SE", PrimaryLanguage::Sami),
        ("sms", PrimaryLanguage::Sami),
        ("sms-FI", PrimaryLanguage::Sami),
        ("sma", PrimaryLanguage::Sami),
        ("sma-NO", PrimaryLanguage::Sami),
        ("sma-SE", PrimaryLanguage::Sami),
        ("sg", PrimaryLanguage::Sango),
        ("sg-CF", PrimaryLanguage::Sango),
        ("sbp", PrimaryLanguage::Sangu),
        ("sbp-TZ", PrimaryLanguage::Sangu),
        ("sa", PrimaryLanguage::Sanskrit),
        ("sa-IN", PrimaryLanguage::Sanskrit),
        ("sc", PrimaryLanguage::Sardinian),
        ("sc-Latn", PrimaryLanguage::Sardinian),
        ("sc-Latn-IT", PrimaryLanguage::Sardinian),
        ("gd", PrimaryLanguage::ScottishGaelic),
        ("gd-GB", PrimaryLanguage::ScottishGaelic),
        ("seh", PrimaryLanguage::Sena),
        ("seh-MZ", PrimaryLanguage::Sena),
        ("sr-Cyrl", PrimaryLanguage::Serbian),
        ("sr-Cyrl-BA", PrimaryLanguage::Serbian),
        ("sr-Cyrl-ME", PrimaryLanguage::Serbian),
        ("sr-Cyrl-RS", PrimaryLanguage::Serbian),
        ("sr-Cyrl-CS", PrimaryLanguage::Serbian),
        ("sr-Latn", PrimaryLanguage::Serbian),
        ("sr", PrimaryLanguage::Serbian),
        ("sr-Latn-BA", PrimaryLanguage::Serbian),
        ("sr-Latn-ME", PrimaryLanguage::Serbian),
        ("sr-Latn-RS", PrimaryLanguage::Serbian),
        ("sr-Latn-CS", PrimaryLanguage::Serbian),
        ("nso", PrimaryLanguage::SesothosaLeboa),
        ("nso-ZA", PrimaryLanguage::SesothosaLeboa),
        ("tn", PrimaryLanguage::Setswana),
        ("tn-BW", PrimaryLanguage::Setswana),
        ("tn-ZA", PrimaryLanguage::Setswana),
        ("ksb", PrimaryLanguage::Shambala),
        ("ksb-TZ", PrimaryLanguage::Shambala),
        ("sn", PrimaryLanguage::Shona),
        ("sn-Latn", PrimaryLanguage::Shona),
        ("sn-Latn-ZW", PrimaryLanguage::Shona),
        ("sd", PrimaryLanguage::Sindhi),
        ("sd-Arab", PrimaryLanguage::Sindhi),
        ("sd-Arab-PK", PrimaryLanguage::Sindhi),
        ("si", PrimaryLanguage::Sinhala),
        ("si-LK", PrimaryLanguage::Sinhala),
        ("sk", PrimaryLanguage::Slovak),
        ("sk-SK", PrimaryLanguage::Slovak),
        ("sl", PrimaryLanguage::Slovenian),
        ("sl-SI", PrimaryLanguage::Slovenian),
        ("xog", PrimaryLanguage::Soga),
        ("xog-UG", PrimaryLanguage::Soga),
        ("so", PrimaryLanguage::Somali),
        ("so-DJ", PrimaryLanguage::Somali),
        ("so-ET", PrimaryLanguage::Somali),
        ("so-KE", PrimaryLanguage::Somali),
        ("so-SO", PrimaryLanguage::Somali),
        ("st", PrimaryLanguage::Sotho),
        ("st-ZA", PrimaryLanguage::Sotho),
        ("nr", PrimaryLanguage::SouthNdebele),
        ("nr-ZA", PrimaryLanguage::SouthNdebele),
        ("st-LS", PrimaryLanguage::SouthernSotho),
        ("es", PrimaryLanguage::Spanish),
        ("es-AR", PrimaryLanguage::Spanish),
        ("es-BZ", PrimaryLanguage::Spanish),
        ("es-VE", PrimaryLanguage::Spanish),
        ("es-BO", PrimaryLanguage::Spanish),
        ("es-BR", PrimaryLanguage::Spanish),
        ("es-CL", PrimaryLanguage::Spanish),
        ("es-CO", PrimaryLanguage::Spanish),
        ("es-CR", PrimaryLanguage::Spanish),
        ("es-CU", PrimaryLanguage::Spanish),
        ("es-DO", PrimaryLanguage::Spanish),
        ("es-EC", PrimaryLanguage::Spanish),
        ("es-SV", PrimaryLanguage::Spanish),
        ("es-GQ", PrimaryLanguage::Spanish),
        ("es-GT", PrimaryLanguage::Spanish),
        ("es-HN", PrimaryLanguage::Spanish),
        ("es-419", PrimaryLanguage::Spanish),
        ("es-MX", PrimaryLanguage::Spanish),
        ("es-NI", PrimaryLanguage::Spanish),
        ("es-PA", PrimaryLanguage::Spanish),
        ("es-PY", PrimaryLanguage::Spanish),
        ("es-PE", PrimaryLanguage::Spanish),
        ("es-PH", PrimaryLanguage::Spanish),
        ("es-PR", PrimaryLanguage::Spanish),
        ("es-ES_tradnl", PrimaryLanguage::Spanish),
        ("es-ES", PrimaryLanguage::Spanish),
        ("es-US", PrimaryLanguage::Spanish),
        ("es-UY", PrimaryLanguage::Spanish),
        ("zgh", PrimaryLanguage::StandardMoroccanTamazight),
        ("zgh-Tfng-MA", PrimaryLanguage::StandardMoroccanTamazight),
        ("zgh-Tfng", PrimaryLanguage::StandardMoroccanTamazight),
        ("ss", PrimaryLanguage::Swati),
        ("ss-ZA", PrimaryLanguage::Swati),
        ("ss-SZ", PrimaryLanguage::Swati),
        ("sv", PrimaryLanguage::Swedish),
        ("sv-AX", PrimaryLanguage::Swedish),
        ("sv-FI", PrimaryLanguage::Swedish),
        ("sv-SE", PrimaryLanguage::Swedish),
        ("syr", PrimaryLanguage::Syriac),
        ("syr-SY", PrimaryLanguage::Syriac),
        ("shi", PrimaryLanguage::Tachelhit),
        ("shi-Tfng", PrimaryLanguage::Tachelhit),
        ("shi-Tfng-MA", PrimaryLanguage::Tachelhit),
        ("shi-Latn", PrimaryLanguage::Tachelhit),
        ("shi-Latn-MA", PrimaryLanguage::Tachelhit),
        ("dav", PrimaryLanguage::Taita),
        ("dav-KE", PrimaryLanguage::Taita),
        ("tg", PrimaryLanguage::Tajik),
        ("tg-Cyrl", PrimaryLanguage::Tajik),
        ("tg-Cyrl-TJ", PrimaryLanguage::Tajik),
        ("tzm", PrimaryLanguage::Tamazight),
        ("tzm-Latn", PrimaryLanguage::Tamazight),
        ("tzm-Latn-DZ", PrimaryLanguage::Tamazight),
        ("ta", PrimaryLanguage::Tamil),
        ("ta-IN", PrimaryLanguage::Tamil),
        ("ta-MY", PrimaryLanguage::Tamil),
        ("ta-SG", PrimaryLanguage::Tamil),
        ("ta-LK", PrimaryLanguage::Tamil),
        ("twq", PrimaryLanguage::Tasawaq),
        ("twq-NE", PrimaryLanguage::Tasawaq),
        ("tt", PrimaryLanguage::Tatar),
        ("tt-RU", PrimaryLanguage::Tatar),
        ("te", PrimaryLanguage::Telugu),
        ("te-IN", PrimaryLanguage::Telugu),
        ("teo", PrimaryLanguage::Teso),
        ("teo-KE", PrimaryLanguage::Teso),
        ("teo-UG", PrimaryLanguage::Teso),
        ("th", PrimaryLanguage::Thai),
        ("th-TH", PrimaryLanguage::Thai),
        ("bo", PrimaryLanguage::Tibetan),
        ("bo-IN", PrimaryLanguage::Tibetan),
        ("bo-CN", PrimaryLanguage::Tibetan),
        ("tig", PrimaryLanguage::Tigre),
        ("tig-ER", PrimaryLanguage::Tigre),
        ("ti", PrimaryLanguage::Tigrinya),
        ("ti-ER", PrimaryLanguage::Tigrinya),
        ("ti-ET", PrimaryLanguage::Tigrinya),
        ("to", PrimaryLanguage::Tongan),
        ("to-TO", PrimaryLanguage::Tongan),
        ("ts", PrimaryLanguage::Tsonga),
        ("ts-ZA", PrimaryLanguage::Tsonga),
        ("tr", PrimaryLanguage::Turkish),
        ("tr-CY", PrimaryLanguage::Turkish),
        ("tr-TR", PrimaryLanguage::Turkish),
        ("tk", PrimaryLanguage::Turkmen),
        ("tk-TM", PrimaryLanguage::Turkmen),
        ("uk", PrimaryLanguage::Ukrainian),
        ("uk-UA", PrimaryLanguage::Ukrainian),
        ("hsb", PrimaryLanguage::UpperSorbian),
        ("hsb-DE", PrimaryLanguage::UpperSorbian),
        ("ur", PrimaryLanguage::Urdu),
        ("ur-IN", PrimaryLanguage::Urdu),
        ("ur-PK", PrimaryLanguage::Urdu),
        ("ug", PrimaryLanguage::Uyghur),
        ("ug-CN", PrimaryLanguage::Uyghur),
        ("uz-Arab", PrimaryLanguage::Uzbek),
        ("uz-Arab-AF", PrimaryLanguage::Uzbek),
        ("uz-Cyrl", PrimaryLanguage::Uzbek),
        ("uz-Cyrl-UZ", PrimaryLanguage::Uzbek),
        ("uz", PrimaryLanguage::Uzbek),
        ("uz-Latn", PrimaryLanguage::Uzbek),
        ("uz-Latn-UZ", PrimaryLanguage::Uzbek),
        ("vai", PrimaryLanguage::Vai),
        ("vai-Vaii", PrimaryLanguage::Vai),
        ("vai-Vaii-LR", PrimaryLanguage::Vai),
        ("vai-Latn-LR", PrimaryLanguage::Vai),
        ("vai-Latn", PrimaryLanguage::Vai),
        ("ca-ES-valencia", PrimaryLanguage::Valencian),
        ("ve", PrimaryLanguage::Venda),
        ("ve-ZA", PrimaryLanguage::Venda),
        ("vi", PrimaryLanguage::Vietnamese),
        ("vi-VN", PrimaryLanguage::Vietnamese),
        ("vo", PrimaryLanguage::Volapk),
        ("vo-001", PrimaryLanguage::Volapk),
        ("vun", PrimaryLanguage::Vunjo),
        ("vun-TZ", PrimaryLanguage::Vunjo),
        ("wae", PrimaryLanguage::Walser),
        ("wae-CH", PrimaryLanguage::Walser),
        ("cy", PrimaryLanguage::Welsh),
        ("cy-GB", PrimaryLanguage::Welsh),
        ("wal", PrimaryLanguage::Wolaytta),
        ("wal-ET", PrimaryLanguage::Wolaytta),
        ("wo", PrimaryLanguage::Wolof),
        ("wo-SN", PrimaryLanguage::Wolof),
        ("xh", PrimaryLanguage::Xhosa),
        ("xh-ZA", PrimaryLanguage::Xhosa),
        ("yav", PrimaryLanguage::Yangben),
        ("yav-CM", PrimaryLanguage::Yangben),
        ("ii", PrimaryLanguage::Yi),
        ("ii-CN", PrimaryLanguage::Yi),
        ("yi", PrimaryLanguage::Yiddish),
        ("yi-001", PrimaryLanguage::Yiddish),
        ("yo", PrimaryLanguage::Yoruba),
        ("yo-BJ", PrimaryLanguage::Yoruba),
        ("yo-NG", PrimaryLanguage::Yoruba),
        ("dje", PrimaryLanguage::Zarma),
        ("dje-NE", PrimaryLanguage::Zarma),
        ("zu", PrimaryLanguage::Zulu),
        ("zu-ZA", PrimaryLanguage::Zulu),
    ]);
}

static LANGUAGE_PRIMARY: &[PrimaryLanguage] = &[
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Afrikaans,
    PrimaryLanguage::Albanian,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Amharic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Arabic,
    PrimaryLanguage::Armenian,
    PrimaryLanguage::Assamese,
    PrimaryLanguage::Azerbaijani,
    PrimaryLanguage::Azerbaijani,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Byelorussian,
    PrimaryLanguage::Bengali,
    PrimaryLanguage::Bengali,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Breton,
    PrimaryLanguage::Bulgarian,
    PrimaryLanguage::Catalan,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::CentralKurdish,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Chinese,
    PrimaryLanguage::Chinese,
    PrimaryLanguage::Chinese,
    PrimaryLanguage::Chinese,
    PrimaryLanguage::Chinese,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Croatian,
    PrimaryLanguage::Croatian,
    PrimaryLanguage::Czech,
    PrimaryLanguage::Danish,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Dutch,
    PrimaryLanguage::Dutch,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::English,
    PrimaryLanguage::Estonian,
    PrimaryLanguage::Faroese,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Finnish,
    PrimaryLanguage::French,
    PrimaryLanguage::French,
    PrimaryLanguage::French,
    PrimaryLanguage::French,
    PrimaryLanguage::French,
    PrimaryLanguage::French,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Galician,
    PrimaryLanguage::Georgian,
    PrimaryLanguage::German,
    PrimaryLanguage::German,
    PrimaryLanguage::German,
    PrimaryLanguage::German,
    PrimaryLanguage::German,
    PrimaryLanguage::Greek,
    PrimaryLanguage::Greenlandic,
    PrimaryLanguage::Gujarati,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Hebrew,
    PrimaryLanguage::Hindi,
    PrimaryLanguage::Hungarian,
    PrimaryLanguage::Icelandic,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Indonesian,
    PrimaryLanguage::Inuktitut,
    PrimaryLanguage::Inuktitut,
    PrimaryLanguage::Irish,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Italian,
    PrimaryLanguage::Italian,
    PrimaryLanguage::Japanese,
    PrimaryLanguage::Kannada,
    PrimaryLanguage::Kazakh,
    PrimaryLanguage::Khmer,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Kinyarwanda,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Korean,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Lao,
    PrimaryLanguage::Latvian,
    PrimaryLanguage::Lithuanian,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Macedonian,
    PrimaryLanguage::Malay,
    PrimaryLanguage::Malay,
    PrimaryLanguage::Malayalam,
    PrimaryLanguage::Maltese,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Marathi,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Mongolian,
    PrimaryLanguage::Mongolian,
    PrimaryLanguage::Nepali,
    PrimaryLanguage::Norwegian,
    PrimaryLanguage::Norwegian,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Pashto,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Polish,
    PrimaryLanguage::Portuguese,
    PrimaryLanguage::Portuguese,
    PrimaryLanguage::Punjabi,
    PrimaryLanguage::Punjabi,
    PrimaryLanguage::Quechua,
    PrimaryLanguage::Quechua,
    PrimaryLanguage::Quechua,
    PrimaryLanguage::Romanian,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Russian,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sami,
    PrimaryLanguage::Sanskrit,
    PrimaryLanguage::ScottishGaelic,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Serbian,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Sindhi,
    PrimaryLanguage::Sinhalese,
    PrimaryLanguage::Slovak,
    PrimaryLanguage::Slovenian,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Spanish,
    PrimaryLanguage::Swedish,
    PrimaryLanguage::Swedish,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Tajiki,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Tamil,
    PrimaryLanguage::Tamil,
    PrimaryLanguage::Tatar,
    PrimaryLanguage::Telugu,
    PrimaryLanguage::Thai,
    PrimaryLanguage::Tibetan,
    PrimaryLanguage::Tigrinya,
    PrimaryLanguage::Tigrinya,
    PrimaryLanguage::Turkish,
    PrimaryLanguage::Turkmen,
    PrimaryLanguage::Uighur,
    PrimaryLanguage::Ukrainian,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Urdu,
    PrimaryLanguage::Urdu,
    PrimaryLanguage::Uzbek,
    PrimaryLanguage::Uzbek,
    PrimaryLanguage::Vietnamese,
    PrimaryLanguage::Welsh,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Unknown,
    PrimaryLanguage::Yiddish,
    PrimaryLanguage::Unknown,
];

#[allow(non_camel_case_types)]
#[repr(u16)]
#[non_exhaustive]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Language {
    Unknown = 0,
    Afrikaans_SouthAfrica,
    Albanian_Albania,
    Alsatian_France,
    Amharic_Ethiopia,
    Arabic_Algeria,
    Arabic_Bahrain,
    Arabic_Egypt,
    Arabic_Iraq,
    Arabic_Jordan,
    Arabic_Kuwait,
    Arabic_Lebanon,
    Arabic_Libya,
    Arabic_Morocco,
    Arabic_Oman,
    Arabic_Qatar,
    Arabic_SaudiArabia,
    Arabic_Syria,
    Arabic_Tunisia,
    Arabic_UAE,
    Arabic_Yemen,
    Armenian_Armenia,
    Assamese_India,
    Azeri_Cyrillic_Azerbaijan,
    Azeri_Latin_Azerbaijan,
    Bashkir_Russia,
    Basque_Basque,
    Belarusian_Belarus,
    Bengali_Bangladesh,
    Bengali_India,
    Bosnian_Cyrillic_BosniaAndHerzegovina,
    Bosnian_Latin_BosniaAndHerzegovina,
    Breton_France,
    Bulgarian_Bulgaria,
    Catalan_Catalan,
    CentralAtlasTamazight_Tifinagh_Morocco,
    CentralKurdish_Iraq,
    Cherokee_Cherokee,
    Chinese_HongKongSAR,
    Chinese_MacaoSAR,
    Chinese_Simplified_PeoplesRepublicOfChina,
    Chinese_Singapore,
    Chinese_Traditional_Taiwan,
    Corsican_France,
    Croatian_Croatia,
    Croatian_Latin_BosniaAndHerzegovina,
    Czech_CzechRepublic,
    Danish_Denmark,
    Dari_Afghanistan,
    Divehi_Maldives,
    Dutch_Belgium,
    Dutch_Netherlands,
    English_Australia,
    English_Belize,
    English_Canada,
    English_Caribbean,
    English_India,
    English_Ireland,
    English_Jamaica,
    English_Malaysia,
    English_NewZealand,
    English_RepublicOfThePhilippines,
    English_Singapore,
    English_SouthAfrica,
    English_TrinidadAndTobago,
    English_UnitedKingdom,
    English_UnitedStates,
    English_Zimbabwe,
    Estonian_Estonia,
    Faroese_FaroeIslands,
    Filipino_Philippines,
    Finnish_Finland,
    French_Belgium,
    French_Canada,
    French_France,
    French_Luxembourg,
    French_PrincipalityOfMonaco,
    French_Switzerland,
    Frisian_Netherlands,
    Galician_Galician,
    Georgian_Georgia,
    German_Austria,
    German_Germany,
    German_Liechtenstein,
    German_Luxembourg,
    German_Switzerland,
    Greek_Greece,
    Greenlandic_Greenland,
    Gujarati_India,
    Hausa_Latin_Nigeria,
    Hawiian_UnitedStates,
    Hebrew_Israel,
    Hindi_India,
    Hungarian_Hungary,
    Icelandic_Iceland,
    Igbo_Nigeria,
    Indonesian_Indonesia,
    Inuktitut_CanadianSyllabics_Canada,
    Inuktitut_Latin_Canada,
    Irish_Ireland,
    isiXhosa_SouthAfrica,
    isiZulu_SouthAfrica,
    Italian_Italy,
    Italian_Switzerland,
    Japanese_Japan,
    Kannada_India,
    Kazakh_Kazakhstan,
    Khmer_Cambodia,
    Kiche_Guatemala,
    Kinyarwanda_Rwanda,
    Kiswahili_Kenya,
    Konkani_India,
    Korean_Korea,
    Kyrgyz_Kyrgyzstan,
    Lao_LaoPDR,
    Latvian_Latvia,
    Lithuanian_Lithuania,
    LowerSorbian_Germany,
    Luxembourgish_Luxembourg,
    Macedonian_NorthMacedonia,
    Malay_BruneiDarussalam,
    Malay_Malaysia,
    Malayalam_India,
    Maltese_Malta,
    Maori_NewZealand,
    Mapudungun_Chile,
    Marathi_India,
    Mohawk_Mohawk,
    Mongolian_Cyrillic_Mongolia,
    Mongolian_Traditional_Mongolia,
    Nepali_Nepal,
    Norwegian_Bokmal_Norway,
    Norwegian_Nynorsk_Norway,
    Occitan_France,
    Odia_India,
    Pashto_Afghanistan,
    Persian_Farsi_Iran,
    Polish_Poland,
    Portuguese_Brazil,
    Portuguese_Portugal,
    Punjabi_India,
    Punjabi_IslamicRepublicOfPakistan,
    Quechua_Bolivia,
    Quechua_Ecuador,
    Quechua_Peru,
    Romanian_Romania,
    Romansh_Switzerland,
    Russian_Russia,
    Sami_Inari_Finland,
    Sami_Lule_Norway,
    Sami_Lule_Sweden,
    Sami_Northern_Finland,
    Sami_Northern_Norway,
    Sami_Northern_Sweden,
    Sami_Skolt_Finland,
    Sami_Southern_Norway,
    Sami_Southern_Sweden,
    Sanskrit_India,
    ScottishGaelic_UnitedKingdom,
    Serbian_Cyrillic_BosniaAndHerzegovina,
    Serbian_Cyrillic_Montenegro,
    Serbian_Cyrillic_Serbia,
    Serbian_Cyrillic_SerbiaAndMontenegro,
    Serbian_Latin_BosniaAndHerzegovina,
    Serbian_Latin_Montenegro,
    Serbian_Latin_Serbia,
    Serbian_Latin_SerbiaAndMontenegro,
    SesothoSaLeboa_SouthAfrica,
    Setswana_Botswana,
    Setswana_SouthAfrica,
    Sindhi_IslamicRepublicOfPakistan,
    Sinhala_SriLanka,
    Slovak_Slovakia,
    Slovenian_Slovenia,
    Spanish_Argentina,
    Spanish_Bolivia,
    Spanish_Chile,
    Spanish_Colombia,
    Spanish_CostaRica,
    Spanish_DominicanRepublic,
    Spanish_Ecuador,
    Spanish_ElSalvador,
    Spanish_Guatemala,
    Spanish_Honduras,
    Spanish_Mexico,
    Spanish_ModernSort_Spain,
    Spanish_Nicaragua,
    Spanish_Panama,
    Spanish_Paraguay,
    Spanish_Peru,
    Spanish_PuertoRico,
    Spanish_TraditionalSort_Spain,
    Spanish_UnitedStates,
    Spanish_Uruguay,
    Spanish_Venezuela,
    Swedish_Finland,
    Swedish_Sweden,
    Syriac_Syria,
    Tajik_Cyrillic_Tajikistan,
    Tamazight_Latin_Algeria,
    Tamil_India,
    Tamil_SriLanka,
    Tatar_Russia,
    Telugu_India,
    Thai_Thailand,
    Tibetan_PeoplesRepublicOfChina,
    Tigrinya_Eritrea,
    Tigrinya_Ethiopia,
    Turkish_Turkey,
    Turkmen_Turkmenistan,
    Uighur_PeoplesRepublicOfChina,
    Ukrainian_Ukraine,
    UpperSorbian_Germany,
    Urdu_India,
    Urdu_IslamicRepublicOfPakistan,
    Uzbek_Cyrillic_Uzbekistan,
    Uzbek_Latin_Uzbekistan,
    Vietnamese_Vietnam,
    Welsh_UnitedKingdom,
    Wolof_Senegal,
    Yakut_Russia,
    Yi_PeoplesRepublicOfChina,
    Yiddish_World,
    Yoruba_Nigeria,
    ___END,
}

impl Language {
    /// Get the primary language.
    pub fn primary(&self) -> PrimaryLanguage {
        LANGUAGE_PRIMARY[*self as usize]
    }
    /// Return the BCP 47 code.
    pub fn to_str(&self) -> &'static str {
        match WINDOWS_TABLE.par_iter().find_any(|&&(_, l, ..)| l == *self) {
            Some(v) => v.2,
            None => "",
        }
    }
    /// Return the BCP 47 primary language.
    pub fn to_str_primary(&self) -> &'static str {
        let lang = self.to_str();
        match lang.find('-') {
            Some(idx) => &lang[0 .. idx],
            None => lang,
        }
    }
}

#[allow(non_camel_case_types)]
#[repr(u16)]
#[non_exhaustive]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum PrimaryLanguage {
    Unknown = 0,
    Afar,
    Afrikaans,
    Aghem,
    Akan,
    Albanian,
    Alsatian,
    Amharic,
    Arabic,
    Armenian,
    Assamese,
    Asturian,
    Asu,
    Aymara,
    Azerbaijani,
    Bafia,
    Bamanankan,
    Bangla,
    Basaa,
    Bashkir,
    Basque,
    Belarusian,
    Bemba,
    Bena,
    Bengali,
    Bhojpuri,
    Blin,
    Bodo,
    Bosnian,
    Breton,
    Bulgarian,
    Burmese,
    Byelorussian,
    Canada,
    Catalan,
    Cebuan,
    Cebuano,
    CentralAtlasTamazight,
    CentralKurdish,
    Chakma,
    Chechen,
    Cherokee,
    Chiga,
    Chinese,
    ChurchSlavic,
    Chuvash,
    CongoSwahili,
    Cornish,
    Corsican,
    Croatian,
    Czech,
    Danish,
    Dari,
    Divehi,
    Duala,
    Dutch,
    Dzongkha,
    Embu,
    English,
    Esperanto,
    Estonian,
    Ewe,
    Ewondo,
    Faroese,
    Farsi,
    Filipino,
    Finnish,
    Flemish,
    French,
    Frisian,
    Friulian,
    Fulah,
    Galician,
    Galla,
    Ganda,
    Georgian,
    German,
    Greek,
    Greenlandic,
    Guarani,
    Gujarati,
    Gusii,
    Haryanvi,
    Hausa,
    Hawaiian,
    Hebrew,
    Hindi,
    Hungarian,
    Icelandic,
    Igbo,
    Indonesian,
    Interlingua,
    Inuktitut,
    Irish,
    Italian,
    Japanese,
    Javanese,
    JolaFonyi,
    Kabuverdianu,
    Kabyle,
    Kaingang,
    Kako,
    Kalenjin,
    Kamba,
    Kannada,
    Kanuri,
    Kashmiri,
    Kazakh,
    Khmer,
    Kiche,
    Kikuyu,
    Kinyarwanda,
    Kirghiz,
    Kiswahili,
    Konkani,
    Korean,
    KoyraboroSenni,
    KoyraChiini,
    Kurdish,
    Kwasio,
    Kyrgyz,
    Lakota,
    Langi,
    Lao,
    Latin,
    Latvian,
    Lingala,
    Lithuanian,
    LowerSorbian,
    LowGerman,
    LubaKatanga,
    Luo,
    Luxembourgish,
    Luyia,
    Macedonian,
    Machame,
    MakhuwaMeetto,
    Makonde,
    Malagasy,
    Malay,
    Malayalam,
    Maltese,
    Manx,
    Maori,
    Mapudungun,
    Marathi,
    Masai,
    Mazanderani,
    Meru,
    Meta,
    Mohawk,
    Moldavian,
    Mongolian,
    Morisyen,
    Mundang,
    Nama,
    Nepali,
    Ngiemboon,
    Ngomba,
    Nheengatu,
    Nko,
    NorthernLuri,
    NorthNdebele,
    Norwegian,
    NorwegianBokml,
    Nuer,
    Nyanja,
    Nyankole,
    Occitan,
    Odia,
    Oriya,
    Oromo,
    Ossetian,
    Pashto,
    Persian,
    Polish,
    Portuguese,
    Prussian,
    PseudoLanguage,
    Punjabi,
    Quechua,
    Rajasthani,
    Ripuarian,
    Romanian,
    Romansh,
    Rombo,
    Rundi,
    Russian,
    Rwa,
    Saho,
    Sakha,
    Samburu,
    Sami,
    Sango,
    Sangu,
    Sanskrit,
    Sardinian,
    ScottishGaelic,
    Sena,
    Serbian,
    SesothosaLeboa,
    Setswana,
    Shambala,
    Shona,
    Sindhi,
    Sinhala,
    Sinhalese,
    Slovak,
    Slovenian,
    Soga,
    Somali,
    Sotho,
    SouthernSotho,
    SouthNdebele,
    Spanish,
    StandardMoroccanTamazight,
    Sundanese,
    Swahili,
    Swati,
    Swedish,
    Syriac,
    Tachelhit,
    Tagalog,
    Taita,
    Tajik,
    Tajiki,
    Tamazight,
    Tamil,
    Tasawaq,
    Tatar,
    Telugu,
    Teso,
    Thai,
    Tibetan,
    Tigre,
    Tigrinya,
    Tongan,
    Tsonga,
    Turkish,
    Turkmen,
    Uighur,
    Ukrainian,
    UpperSorbian,
    Urdu,
    Uyghur,
    Uzbek,
    Vai,
    Valencian,
    Venda,
    Vietnamese,
    Volapk,
    Vunjo,
    Walser,
    Welsh,
    Wolaytta,
    Wolof,
    Xhosa,
    Yangben,
    Yi,
    Yiddish,
    Yoruba,
    Zarma,
    Zulu,
    ___END,
}

impl PrimaryLanguage {
    /// Return the BCP 47 code.
    pub fn to_str(&self) -> &'static str {
        match MACOS_TABLE.par_iter().find_any(|&&(_, v, ..)| v == *self) {
            Some(v) => v.2,
            None => "",
        }
    }
    /// Return the BCP 47 primary language.
    pub fn to_str_primary(&self) -> &'static str {
        let lang = self.to_str();
        match lang.find('-') {
            Some(idx) => &lang[0 .. idx],
            None => lang,
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::mem::transmute;

    #[test]
    fn lang_basic() {
        let max = Language::___END as u16;
        assert_eq!(max as usize, LANGUAGE_PRIMARY.len());
        for i in 0 .. max {
            let lang = unsafe { transmute::<u16, Language>(i) };
            let be_prim = lang.primary();
            print!("{:?}, {:?}. ", lang, be_prim);
            if be_prim == PrimaryLanguage::Unknown {
                println!("By pass");
            } else {
                let l_p = lang.to_str_primary();
                let b_p = be_prim.to_str_primary();
                println!("{}, {}", lang.to_str(), be_prim.to_str());
                assert!(is_same_primary_language(
                    lang.to_str(),
                    be_prim.to_str()
                ));
                assert!(is_same_primary_language(l_p, b_p));
            }
        }
    }
}
